LadyDragon
Programmer
I am trying to set up a textbox within a datagrid and I'm not sure how to do it. Here is the code I'm working on. I would like these cells to be textboxes that the user can modify the values and hit a save button for processing. Right now, I can set the cell text, but am unable to figure out how to make the cell a textbox:
Looking through some code elsewhere in the app, it appears that this code snippet is working how I would like my code to work, but I don't understand what the Textbox tb line is doing. I've attempted to set my code up similarly, but get an index error on this line. If anyone can help me understand how this is working, I would appreciate it.
I appreciate your help!
Thanks,
Juls
Code:
TableRow tr = Table3.Rows[3];
for(int j = 1; j< 8; j++)
{
tr.Cells[j].Text = "My text";
TableCell tc = tr.Cells[j];
}
tr = Table3.Rows[4];
for(int j = 1; j< 8; j++)
{
tr.Cells[j].Text = "My text";
TableCell tc = tr.Cells[j];
}
Looking through some code elsewhere in the app, it appears that this code snippet is working how I would like my code to work, but I don't understand what the Textbox tb line is doing. I've attempted to set my code up similarly, but get an index error on this line. If anyone can help me understand how this is working, I would appreciate it.
Code:
TableRow tr = Table3.Rows[4];
tr.Cells[7].Text = "seven";
tr.Cells[6].Text = "six";
tr.Cells[5].Text = "five";
tr.Cells[4].Text = "four";
tr.Cells[3].Text = "three";
tr.Cells[2].Text = "two";
tr.Cells[1].Text = "one";
TableCell tc = tr.Cells[8];
TextBox tb = (TextBox)tc.Controls[0]; /* How is this textbox set?*/
string sav1 = string.Empty, sav2 = string.Empty;
if (tb != null)
{
tb.Text = "test";
sav1 = tb.Text;
}
I appreciate your help!
Thanks,
Juls