0

動的グリッドビューを作成し、そのグリッドビュー内で、そのグリッドビューをリストボックスアイテムにバインドしたいと思います。グリッドビューの最初の2列をチェックボックスとして、3番目の項目をリストボックスの項目として使用します。こんなもの欲しい

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.
}

どうすればこれを達成できますか?

4

1 に答える 1

0

GridView の on databound イベントのイベント ハンドラーを追加するだけです。つまり、現在の行、列、およびその行のデータにアクセスし、任意のオプション (テキスト、チェック済み、無効など) を使用してその行にコントロールを追加できます。あなたが必要です。

于 2012-11-21T06:49:03.790 に答える