我有幾個動態創建的複選框,現有選擇將顯示,但是當用戶進行更改時,我想將它們存儲回來。這裏是產生並動態地選擇如何保存動態複選框更改
private void Role(string role)
{
SystemUserDal dal = new SystemUserDal();
var userId = Guid.Parse(Request.QueryString["ID"].ToString());
var roles = dal.GetRolesList(userId);
foreach (KeyValuePair<Guid, string> r in roles)
{
CheckBox chk = new CheckBox();
chk.ID = r.Value;
chk.Text = r.Value;
if (role.Contains(r.Value))
{
chk.Checked = true;
}
rolepanel.Controls.Add(chk);
}
}
我想下面
private void GetCheckBoxes()
{
foreach (Control ctrl in rolepanel.Controls)
{
CheckBox c = ctrl as CheckBox;
string id = c.ID;
string role = c.Text;
}
}
當我通過代碼它擊中以計數3 foreach循環的代碼,但CTL爲空。任何線索?
什麼是'rolepanel'的類型? – PoweredByOrange
它的ASP面板動態複選框加載 – user2167089
程序員93它的ASP面板動態複選框將加載 – user2167089