-
combo box values
hello i have these codes in a page:
1st loop:
Code:
for (int i = 1; i <= recordCount5; i++)
{
if (dr.HasRows)
{
dr.Read();
////1st row - Add Text to cell and add Cell to Row
htRow = new HtmlTableRow();
htCell = new HtmlTableCell();
htCell.Align = "left";
htCell.InnerText = "***" + dr["QUESTION"].ToString(); htRow.Cells.Add(htCell);
tbl.Rows.Add(htRow);
htCell = new HtmlTableCell();
DropDownList cbo5 = new DropDownList();
cbo5.SelectedIndexChanged += new EventHandler(cbo5_SelectedIndexChanged);
cbo5.ID = "cbo5" + i.ToString();
cbo5.Items.Add("");
cbo5.Items.Add("1");
cbo5.Items.Add("2");
cbo5.Items.Add("3");
cbo5.Items.Add("4");
cbo5.Items.Add("5");
htCell.Controls.Add(cbo5);
htRow.Cells.Add(htCell);
}
}
2nd loop:
Code:
for (int i = 1; i <= recordCount6; i++)
{
if (dr.HasRows)
{
dr.Read();
////1st row - Add Text to cell and add Cell to Row
htRow = new HtmlTableRow();
htCell = new HtmlTableCell();
htCell.Align = "left";
htCell.InnerText = " " + dr["QUESTION"].ToString(); htRow.Cells.Add(htCell);
tbl.Rows.Add(htRow);
htCell = new HtmlTableCell();
DropDownList cbo6 = new DropDownList();
cbo5.SelectedIndexChanged += new EventHandler(cbo5_SelectedIndexChanged);
cbo6.ID = "cbo6" + i.ToString();
cbo6.Items.Add("");
cbo6.Items.Add("1");
cbo6.Items.Add("2");
cbo6.Items.Add("3");
cbo6.Items.Add("4");
cbo6.Items.Add("5");
htCell.Controls.Add(cbo6);
htRow.Cells.Add(htCell);
}
}
how would i get all the values in the loop?
tnx
-
Re: combo box values
-
Re: combo box values
Hey,
Like Mend, I am really not sure that I understand the question. Can you provide some more context as to what exactly you are trying to achieve?
Gary
-
Re: combo box values
ok. in the example above imagine that there are 10 comboboxes then
how can i get all values in the 10 comboboxes take note that the comboboxes are dynamic they are created in run time.
tnx
-
Re: combo box values
this was solved by doing below.
Code:
protected void Button1_Click(object sender, EventArgs e)
{
for (int i = 1; i <= 10; i++)
{
lblError.Text = lblError.Text + (DropDownList)this.FindControl("cbo5" + i)).Text;
}
}
-
Re: combo box values
Hey,
I am still not sure exactly what you are trying to achieve, but it sounds like you have got what you wanted.
Remember to mark your thread resolved.
Gary