我想创建一个动态网格视图,并在该网格视图内,我想将该网格视图与一个列表框项绑定。我希望gridview的前两列作为复选框,第三项作为列表框中的项目。我想要这样的东西
foreach (ListItem item in Listbox1.Items)
{
if (item.Selected)
{
Listbox2.Items.Add(new ListItem(item.Text, item.Value));
}
}
GridView gridview1 = new GridView();
foreach(ListItem item in Listbox2.Items)
{
CheckBoxField chk = new CheckBoxField();
chk.HeaderText = "Test1";
gridview1.Columns.Add(chk);
CheckBoxField chk2 = new CheckBoxField();
chk.HeaderText = "Test2";
gridview1.Columns.Add(chk);
// another columns that displays the item from the list box
// another column that displays the value of the item of the listbox, but the column is hidden.
}
我怎样才能做到这一点?