本文介绍了动态添加的Checked Changed事件未触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经动态添加了列和复选框...但是遇到了一个问题,即未触发CheckedChanged事件.这是我的代码..
I have addded columns and checkboxes Dynamically... But met with a problem that the CheckedChanged Event is not fired.. here is my Code..
// binding datatable Dynamically..
protected void ddlRole_SelectedIndexChanged(object sender, EventArgs e)
{
for (int i = 0; i < DtOperation.Rows.Count; i++)
{
Dt.Columns.Add(DtOperation.Rows[i][0].ToString());
}
dgrDynamic.DataSource = Dt;
dgrDynamic.DataBind();
.
.
//addind check boxes dynamically.
tcCheckCell = new TableCell();
var checkBox = new CheckBox();
// ActivityID|OperationID is stored to work it at the time of Save in CheckedChanged.
checkBox.ID = DtOperation.Rows[i][0] + "|" + DtOperation.Rows[i][2];
checkBox.AutoPostBack = true;
checkBox.Checked = true;
checkBox.CheckedChanged +=new EventHandler(checkBox_CheckedChanged);
tcCheckCell.Controls.Add(checkBox);
dgrDynamic.Rows[j].Cells.RemoveAt(GetColumnIndexByName((int)DtOperation.Rows[i][2]));
dgrDynamic.Rows[j].Cells.AddAt(GetColumnIndexByName((int)DtOperation.Rows[i][2]), tcCheckCell);
//(int)DtOperation.Rows[i][2]+2
}
void checkBox_CheckedChanged(object sender, EventArgs e)
{
...Code;
}
在这个领域比较新鲜,请您帮我克服痛苦..谢谢大家
am a fresher in this field and can you pls help me to Over come the misery.. Thank you all
推荐答案
这篇关于动态添加的Checked Changed事件未触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!