0
我想創建一個動態的gridview,並在該gridview,我想綁定該gridview與列表框項目。我希望GridView的前兩列作爲複選框,而第三項作爲列表框中的項目。我想是這樣的動態創建gridview與複選框insdie它
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.
}
我怎樣才能達致這。
感謝您的幫助。