0

DataTable新しい列をに挿入してから、テーブルの各行に RadioButton を挿入しようとしています。

新しい列を追加しました:

datasource.Columns.Add("RadioButtons");

その後、このテーブルに RadioButton foreach 行を追加しようとしました。

foreach (DataRow dr in datasource.Rows)
{
   dr[4] = new RadioButton();                        
   (dr[4] as RadioButton).GroupName = "Room1";
   Wizard1.ActiveStep.Controls.Add((Control)dr[4]);                        
}

そして、GroupName を設定している場所でエラーが発生します。

オブジェクト参照がオブジェクト インスタンスに設定されていません。

私は何を間違っていますか?

4

1 に答える 1

0

DataType RadioButton を持つ列がないため、RadioButton の汎用リストを試すことができます

お気に入り

 List<RadioButton> List1 = New List<RadioButton>
于 2013-01-12T14:13:55.147 に答える