如何将TextBox中用户输入的值赋给RadioButtonList的某个成员?
例如将“tb1”和“tb2”中的值分别赋给“rbl1”中的成员[0]和[1],用下面的
protected void rbl1_SelectedIndexChanged(object sender, EventArgs e)
{
if (rbl1.Items[0].Selected == true)
{
rbl1.Items[0].Value = tb1.Text;
}
if (rbl1.Items[1].Selected == true)
{
rbl1.Items[1].Value = tb2.Text;
}
}
------解决方案--------------------------------------------------------
for (int i = 0; i < rbl1.Items.Count; i++)
{
if (rbl1.Items[i].Selected) rbl1.Items[i].Value = (Controls["tb" + i] as TextBox).Text;
}
------解决方案--------------------------------------------------------
+++