次のようなaspページのループでテーブルを作成しています:
foreach (ListItem item in check.Items)
{
if (item.Selected)
{
DropDownList drop = new DropDownList();
drop.Items.Add("1");
drop.Items.Add("2");
drop.DataValueField = "1";
drop.DataValueField = "2";
TableRow row = new TableRow();
TableCell celula = new TableCell();
celula.Style.Add("width", "200px");
celula.Style.Add("background-color", "red");
celula.RowSpan = 2;
celula.Text = item.Value;
TableCell celula1 = new TableCell();
celula1.Style.Add("background-color", "green");
celula1.Style.Add("width", "200px");
celula1.RowSpan = 2;
TableCell celula2 = new TableCell();
celula2.Style.Add("width", "200px");
celula2.Style.Add("background-color", "blue");
celula2.Text = "unu";
TableRow row1 = new TableRow();
TableCell cel = new TableCell();
cel.Text = "lalala";
cel.Style.Add("background-color", "brown");
celula1.Controls.Add(drop);
row.Cells.Add(celula);
row.Cells.Add(celula1);
row.Cells.Add(celula2);
row1.Cells.Add(cel);
this.tabel.Rows.Add(row);
this.tabel.Rows.Add(row1);
}
}
チェックした値ごとに、チェックしたチェックボックスの値、ドロップダウンリスト、およびさらに 2 つのセルを含む新しい行が作成されます。ここで、作成するドロップダウンリストごとに何かを作成したいので、最初の行に 1 を選択すると何かが表示され、別の行に 1 を選択すると別のものが表示されます。selectedindexchanged を作成しましたが、最初の行から 1 を選択すると、両方の行に表示されます。ループで作成した各ドロップダウンリストを個別に参照するにはどうすればよいですか?? 私はC#でAsp.Net Webアプリケーションを使用しています