对于正常的checkboxlist我使用这些绑定是有效的,但是如何动态地在gridview中为每一行绑定。
List<string> availableItems = new List<string> { "Item1", "Item2", "Item3", "Item4", "Item5" };
List<string> selectedItems = new List<string> { "Item1", "Item3", "Item4", "Item6" };
// add available items to checkboxlist control
foreach (string item in availableItems)
chkItems.Items.Add(new ListItem(item));
// check pre-selected items
var query = from ListItem listItem in chkItems.Items
join item in selectedItems
on listItem.Value equals item
select listItem;
foreach (ListItem listItem in query)
listItem.Selected = true;
答案 0 :(得分:1)
使用FindControl在RadGrid ItemCreated中找到checkBoxList并绑定它。