I create a number of CheckboxList Controls in my code-behind (in Page_Load), which are put into an UpdatePanel. The UpdatePanel is set up for UpdateMode="always", so if I understood correctly, every Postback from within this UpdatePanel should trigger a Postback on the whole Updatepanel (which is what I want).
Simplified aspx-markup:
<asp:UpdatePanel ID="updatepanel_profiles_manualdata" runat="server">
<ContentTemplate>
<div id="cbl_container" runat="server">
</div>
</ContentTemplate>
</asp:UpdatePanel>
Simplified code-behind:
protected void create_cbl(){
// this is called in Page_Load
CheckBoxList mycbl = new CheckBoxList();
mycbl.SelectedIndexChanged += new EventHandler(cbl_manual_clickEvent);
DataTable dt3 = get_cbl_data(someparameter);
mycbl.DataSource = dt3;
mycbl.DataTextField = "Title";
mycbl.DataValueField = "ID";
mycbl.AutoPostBack = true;
mycbl.DataBind();
//add the checkboxlist to the container-div in the aspx-markup
cbl_container.Controls.Add(mycbl);
}
protected void cbl_manual_clickEvent(object sender, EventArgs e){
// do something with this click...
}
Struggles:
- I tried setting a breakpoint into my cbl_manual_clickEvent - it is never reached, but the page compiles without an error.
- I have another CheckBoxList in the same UpdatePanel, initialized in the markup and therefore the OnSelectedIndex event is bound within the markup. Postback works just fine here. However I need to create the second CheckBoxList from code-behind, as the amount depends on some data within a database.
- I tried setting ChildrenAsTriggers="true" in the UpdatePanel, as well as changing the UpdateMode and defining triggers, without any luck.
What am I missing? Thanks in advance for all hints or suggestions...!