怎么绑定的??
RadioButtonList 获取的只有一个值
CheckBoxList 获取的是多个值
给你两个方法参考下
public static class UIMgr
{
///
/// 获取ListControl的值
///
///
///
public static string GetVal(this ListControl list)
{
StringBuilder val = new StringBuilder();
foreach (ListItem li in list.Items)
{
if (!li.Selected) continue;
val.Append(li.Value).Append(",");
}
return val.ToString().TrimEnd(',');
}
///
/// 绑定ListControl的值
///
///
///
public static void BindVal(this ListControl list, string val)
{
string[] valArr = val.Split(',');
foreach (string v in valArr)
{
if (string.IsNullOrEmpty(v)) continue;
ListItem li = list.Items.FindByValue(v);
if (li == null) continue;
li.Selected = true;
}
}
}
RadioButtonList rbl=(RadioButtonList)datalist.control("RadioButtonList1")
这样通过rbl就可以获取RadioButtonList的值,CheckBoxList同理