asp.net中,给RadioButtonList动态赋值?

2024-12-03 17:46:00
推荐回答(4个)
回答1:

<%
RadioButtonList1.Items.Add(new ListItem("100~90分", "O"));
RadioButtonList1.Items.Add(new ListItem("90~80分", "V"));
RadioButtonList1.Items.Add(new ListItem("80~70", "G"));
RadioButtonList1.Items.Add(new ListItem("80~70", "I"));
RadioButtonList1.Items.Add(new ListItem("80~70", "U"));

string Score = "V";
ListItem item = RadioButtonList1.Items.Cast().Where(o => o.Value == Score).SingleOrDefault();
int index = RadioButtonList1.Items.IndexOf(item);

if (item!=null)
{
RadioButtonList1.SelectedIndex = index;
}
else
{
RadioButtonList1.Items.Add(new ListItem("数据库添加",Score));
}

%>

回答2:

数据库中Score的值不要为空,设为 -1

回答3:

单选按钮

回答4:

判断啊