动态添加Radiobuttons到Treeview没有触发事件

时间:2012-11-01 18:31:19

标签: dynamic event-handling treeview radio-button

我需要在每个节点的右侧动态添加单选按钮,如果用户点击,我需要在数据库中进行一些更改。

目前我正在使用Radiobutton构建一个表并将其添加到Treeview节点的节点文本中。一切都很好但是Eventhandler无法正常工作。

有人可以帮帮我吗。

HtmlTable oItemTable = new HtmlTable();
oItemTable.Width = "100%";
HtmlTableRow oItemRow = new HtmlTableRow();
HtmlTableCell oItemDescCell = new HtmlTableCell();
oItemDescCell.Width = "200px";
oItemDescCell.InnerText = sItemID;
oItemRow.Cells.Add(oItemDescCell);

HtmlTableCell oItemMonitorCell = new HtmlTableCell();
oItemMonitorCell.Width = "10px";
RadioButton rdbItemMonitor = new RadioButton();
rdbItemMonitor.ID = sItemID + "M";
rdbItemMonitor.GroupName = sItemID;
rdbItemMonitor.AutoPostBack = true;
rdbItemMonitor.CheckedChanged += new EventHandler(rdbItemMonitor_OnCheckedChanged);
oItemMonitorCell.Controls.Add(rdbItemMonitor);
oItemRow.Cells.Add(oItemMonitorCell);
StringBuilder sbItemTable = new StringBuilder();
using (StringWriter swItemTable = new StringWriter(sbItemTable))
{
using (HtmlTextWriter twSegmentTable = new HtmlTextWriter(swItemTable))
{
oItemTable.RenderControl(twSegmentTable);
}
}

oNodeItem.Text = sbItemTable.ToString();
trvMyPlans.Nodes.Add(oNodeItem);

0 个答案:

没有答案