flnMichael
Programmer
Hey,
I have a piece of code below in which I am creating multiple rows on a dynamic table, each with a number of text fields I have to gather on a button click. My question is how do I access each text field? I have named them according to a static name + the row number in which it falls into. How do I incorporate the row number in the name when I get to it in my loop?
int max_parms = 32;
int max_parm_count;
for (max_parm_count = 1; max_parm_count <= max_parms; max_parm_count++)
{
TableRow tr2 = new TableRow();
TableCell MSN = new TableCell();
TextBox _MSN = new TextBox();
_MSN.Width = 80;
_MSN.ID = "MSN" + max_parm_count.ToString();
_MSN.Text = "";
_MSN.Enabled = true;
MSN.Controls.Add(_MSN);
tr2.Cells.Add(MSN);
tblDynamic.Rows.Add(tr2);
}
TableRow row1 = new TableRow();
TableCell RunTestBtn = new TableCell();
RunTestBtn.HorizontalAlign = HorizontalAlign.Center;
Button _RunTestBtn = new Button();
_RunTestBtn.ID = "RunTestBtn";
_RunTestBtn.Text = "Run Test";
_RunTestBtn.Click += new EventHandler(_RunTestBtn_Click);
RunTestBtn.Controls.Add(_RunTestBtn);
row1.Cells.Add(RunTestBtn);
tblSaveQuitPrint.Rows.Add(row1);
private void _RunTestBtn_Click(object sender, System.EventArgs e)
{
int i = 1;
int flag = 0;
while(i < 32)
{
// This is the line I need to figure out
if(MSN+i.ToString() == "")
{
flag = 1;
break;
}
i = i + 1;
}
}
Any help would be appreciated.
Thanks
Mike
I have a piece of code below in which I am creating multiple rows on a dynamic table, each with a number of text fields I have to gather on a button click. My question is how do I access each text field? I have named them according to a static name + the row number in which it falls into. How do I incorporate the row number in the name when I get to it in my loop?
int max_parms = 32;
int max_parm_count;
for (max_parm_count = 1; max_parm_count <= max_parms; max_parm_count++)
{
TableRow tr2 = new TableRow();
TableCell MSN = new TableCell();
TextBox _MSN = new TextBox();
_MSN.Width = 80;
_MSN.ID = "MSN" + max_parm_count.ToString();
_MSN.Text = "";
_MSN.Enabled = true;
MSN.Controls.Add(_MSN);
tr2.Cells.Add(MSN);
tblDynamic.Rows.Add(tr2);
}
TableRow row1 = new TableRow();
TableCell RunTestBtn = new TableCell();
RunTestBtn.HorizontalAlign = HorizontalAlign.Center;
Button _RunTestBtn = new Button();
_RunTestBtn.ID = "RunTestBtn";
_RunTestBtn.Text = "Run Test";
_RunTestBtn.Click += new EventHandler(_RunTestBtn_Click);
RunTestBtn.Controls.Add(_RunTestBtn);
row1.Cells.Add(RunTestBtn);
tblSaveQuitPrint.Rows.Add(row1);
private void _RunTestBtn_Click(object sender, System.EventArgs e)
{
int i = 1;
int flag = 0;
while(i < 32)
{
// This is the line I need to figure out
if(MSN+i.ToString() == "")
{
flag = 1;
break;
}
i = i + 1;
}
}
Any help would be appreciated.
Thanks
Mike