Click here to Skip to main content
15,897,704 members
Home / Discussions / C#
   

C#

 
GeneralLoggin in C# Pin
rnvrnv13-Jul-05 5:31
rnvrnv13-Jul-05 5:31 
GeneralRe: Loggin in C# Pin
S. Senthil Kumar13-Jul-05 6:31
S. Senthil Kumar13-Jul-05 6:31 
GeneralRe: Loggin in C# Pin
eggie513-Jul-05 6:55
eggie513-Jul-05 6:55 
GeneralRe: Loggin in C# Pin
Steve Maier13-Jul-05 7:18
professionalSteve Maier13-Jul-05 7:18 
GeneralHuge problem with controls Pin
zaboboa13-Jul-05 5:17
zaboboa13-Jul-05 5:17 
GeneralRe: Huge problem with controls Pin
Judah Gabriel Himango13-Jul-05 10:47
sponsorJudah Gabriel Himango13-Jul-05 10:47 
GeneralRe: Huge problem with controls Pin
jdkulkarni14-Jul-05 2:49
jdkulkarni14-Jul-05 2:49 
QuestionHow do I get client input from dynamically created controls that I can use in server-side code??? Pin
jengbrecht13-Jul-05 5:13
jengbrecht13-Jul-05 5:13 
I am creating a website where I populate an html table with rows of data that I acquire from a database. For each record in the database, a new row is created in the table with various controls like dropdownboxes, text inputs, buttons, etc. (some are html controls, some are asp controls). Each control is given a unique ID based on the record number/row in the table (ex. btnUpdate_1, btnUpdate_2, etc.). What I am trying to accomplish is, that if the user clicks the Update button (I don't care if the button is an asp or html control), I want to be able to grab the data they entered or changed in the all the other controls in that same row - the dropdownboxes, text inputs, etc. - so that I can then go and update the database. However, I cannot access these controls on the server-side since they are created dynamically and I've tried using some javascript to get the data, but even then, I can only seem to use the data on the client side & am unable to figure out how to use it on the server-side. I hope all this mumble-jumble makes sense. But here is some example code of how the controls are being created...

protected System.Web.UI.WebControls.PlaceHolder plcQ;

private void Page_Load(object sender, System.EventArgs e)
{
string projPath = @"m:Survey\";

Session["myQConn"] = "Provider=MSDASQL/SQLServer ODBC;Driver={Microsoft Visual FoxPro Driver};" + "SourceType=DBF;SourceDB=" + projPath + ";InternetTimeout=300000;Transact Updates=True";

ReadQs(Session["myQConn"].ToString());
}

public void ReadQs(string myConnString)
{
string mySelectQuery = "SELECT * FROM QUESTION";
OdbcConnection myConnection = new OdbcConnection(myConnString);
OdbcCommand myCommand = new OdbcCommand(mySelectQuery, myConnection);
myConnection.Open();
OdbcDataReader myReader;
myReader = myCommand.ExecuteReader();

plcQ.Controls.Add(new LiteralControl("<table>"));

decimal counter = 0;
string strMin = string.Empty;
string strMax = string.Empty;
string strConfirm = string.Empty;

while (myReader.Read())
{
counter = counter + 1;
strMin = myReader.GetString(2).Trim();
strMax = myReader.GetString(3).Trim();
strConfirm = myReader.GetString(6).Trim();

plcQ.Controls.Add(new LiteralControl("<tr>"));

// Create server-side ASP Update Button
Button btnUpdate = new Button();
btnUpdate.ID = "btnUpdate_" + counter;
btnUpdate.Text = "Update";
btnUpdate.Click += new System.EventHandler(this.btnUpdate_Click);

// Add button to placeholder
plcQ.Controls.Add(new LiteralControl("<td>"));
plcQ.Controls.Add(btnUpdate);
plcQ.Controls.Add(new LiteralControl("</td>"));

// Add HTML text input boxes to placeholder
plcQ.Controls.Add(new LiteralControl("<td><input type='text' name='minimum_" + counter + "' value='" + strMin + "'></td>"));
plcQ.Controls.Add(new LiteralControl("<td><input type='text' name='maximum_" + counter + "' value='" + strMax + "'></td>"));

// Add HTML drop down box to placeholder
plcQ.Controls.Add(new LiteralControl("<td><select name='confirm_" + counter + "'>"));
if(strConfirm == "T")
plcQ.Controls.Add(new LiteralControl("<option value='T' selected>T</option><option value='F'>F</option></select></td></tr>"));
else
plcQ.Controls.Add(new LiteralControl("<option value='T'>T</option><option value='F' selected>F</option></select></td></tr>"));
}

plcQ.Controls.Add(new LiteralControl("</table>"));

myReader.Close();

myConnection.Close();
}

So, the question is, when the user clicks btnUpdate_3, how do I get whatever they entered in minimum_3 (input text), maximum_3 (input text), and confirm_3 (select) so that I can do an update on my database??? (I have also tried using an html button control, but had the same issues) – HELP!


Generalfinding control in datagrid header Pin
livez13-Jul-05 4:52
livez13-Jul-05 4:52 
GeneralRe: finding control in datagrid header Pin
thomasa22-Jul-05 2:06
thomasa22-Jul-05 2:06 
Generaldisable browsing directory Pin
Emily7713-Jul-05 3:54
Emily7713-Jul-05 3:54 
GeneralRe: disable browsing directory Pin
Guffa13-Jul-05 4:43
Guffa13-Jul-05 4:43 
QuestionHow tocall Asynchronous webservice for my code Pin
Vinkum13-Jul-05 3:51
Vinkum13-Jul-05 3:51 
General.NET Project renamer free tool Pin
Anonymous13-Jul-05 3:36
Anonymous13-Jul-05 3:36 
GeneralAnother stinking ad! Pin
Dave Kreskowiak13-Jul-05 5:13
mveDave Kreskowiak13-Jul-05 5:13 
Generalpassing struct to web service Pin
fady_sayegh13-Jul-05 3:35
fady_sayegh13-Jul-05 3:35 
GeneralRe: passing struct to web service Pin
Guffa13-Jul-05 4:49
Guffa13-Jul-05 4:49 
GeneralRe: passing struct to web service Pin
fady_sayegh13-Jul-05 4:53
fady_sayegh13-Jul-05 4:53 
GeneralRe: passing struct to web service Pin
fady_sayegh13-Jul-05 4:57
fady_sayegh13-Jul-05 4:57 
GeneralIf dircectX is not installed and i have all the dll's and stuff... Pin
Anthony Mushrow13-Jul-05 3:17
professionalAnthony Mushrow13-Jul-05 3:17 
GeneralRe: If dircectX is not installed and i have all the dll's and stuff... Pin
Dave Kreskowiak13-Jul-05 5:11
mveDave Kreskowiak13-Jul-05 5:11 
GeneralRe: If dircectX is not installed and i have all the dll's and stuff... Pin
Steve Maier13-Jul-05 7:24
professionalSteve Maier13-Jul-05 7:24 
GeneralRe: If dircectX is not installed and i have all the dll's and stuff... Pin
Dave Kreskowiak13-Jul-05 9:08
mveDave Kreskowiak13-Jul-05 9:08 
QuestionShowing MDIChild modally? Pin
zaboboa13-Jul-05 2:54
zaboboa13-Jul-05 2:54 
AnswerRe: Showing MDIChild modally? Pin
Dave Kreskowiak13-Jul-05 5:08
mveDave Kreskowiak13-Jul-05 5:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.