datalist中的checkbox
datalist 中每行有个checkbox , 取得checkbox选中行的datakeyfield的值
------解决方案--------------------// 假设你的 ID 类型为 int
// asp.net 1.x
// IList idList = new ArrayList();
// asp.net 2.0
IList <int> idList = new List <int> ();
foreach(DataListItem item in MyDataList.Items)
{
CheckBox chk = item.FindControl( "MyCheckBoxID ") as CheckBox;
if(chk != null && chk.Checked) {
//idList.Add(MyDataList.DataKeys[item.ItemIndex]);
idList.Add((int)MyDataList.DataKeys[item.ItemIndex]);
}
}
Good Luck!