0
我已經在button1的click事件中動態創建了一個複選框數組。現在我想在另一個button2點擊事件中檢查它的checked屬性。由於複選框控件是在運行時動態創建的,因此我無法在button2單擊事件中訪問它。請有人幫我解決這個問題。如何在另一個事件處理程序方法中訪問動態創建的CheckBox事件狀態
public void Display(ref string[] strDmn, ref string[][] strAvblty)
{
ch = new CheckBox[cntExt/2];
strDomInfo = new string[cntExt/2];
Table t = new Table();
t.Caption = "Domain Availablity";
t.BorderWidth = 1;
TableRow tr;
TableCell tc;
System.Drawing.ColorConverter colConvert = new ColorConverter();
for (int i = 0; i < (strDmn.Length); i++)
{
for (int l = 0; l < ((strAvblty[i].Length)/2); l++)
{
tr = new TableRow();
tr.BackColor = (System.Drawing.Color)colConvert.ConvertFromString("#F0E8FF");
for (int j = 0; j < 4; j++)
{
//string k = strAvblty[i][(i * 2 + 1)];
tc = new TableCell();
tc.Width = 300;
switch (j)
{
case 0:
ch[k - 1] = new CheckBox();
strDomInfo[k - 1] = strDmn[i] + "." + strAvblty[i][(l * 2)];
if (strAvblty[i][(l * 2) + 1] == "available")
{ }
else { ch[k - 1].Enabled = false; }
tc.Controls.Add(ch[k - 1]);
break;
case 1: tc.Text = strDmn[i];
break;
case 2: tc.Text = strAvblty[i][(l * 2)];
break;
case 3: tc.Text = strAvblty[i][(l * 2) + 1];
break;
}
tr.Cells.Add(tc);
}
t.Rows.Add(tr);
}
}
// desiredPanel is your panel
Panel1.Controls.Add(t);
}
protected void btnAdd2Cart_Click(object sender, EventArgs e)
{
//******I have get the boolen check property here ******
}