c#中DataList的问题
来源:百度知道 编辑:UC知道 时间:2024/06/25 02:25:11
for (int i = 0; i < DataList1.Items.Count; i++)
{
RadioButtonList RBL=(RadioButtonList)Datalist1.items[i].FindControl("RadioButtonList1");
String aaa=RBL.Selecteditem.text.tostring();
}
我在做在线考试系统的时候遇到同样的问题,最后有办法解决,不过我不是用RadioButtonList,我是用了四个RadioButton,因为我做的是选择题,所以有四个选项,分别用了四个RadioButton来供选择:
for (int i = 0; i < DataList1.Items.Count; i++)
{
CheckBox tm1 = (CheckBox)DataList1.Items[i].FindControl("RadioButton1");
if (tm1.Checked)
{
//RadioButton1就被选中了
}
CheckBox tm2 = (CheckBox)DataList1.Items[i].FindControl("RadioButton2");
if (tm2.Checked)
{
//RadioButton2就被选中了
}
CheckBox tm3 = (CheckBox)DataList1.Items[i].FindControl("RadioButton3");
if (tm3.Checked)
{
//RadioButton3就被选中了
}
CheckBox tm4 = (CheckBox)DataList1.Items[i].FindControl("RadioButton4");
if (tm4.Checked)