!IsPostBack problem when Dynamically adding the checkbox control

myzona

New Member
I have a ascx page in which i am adding checkbox dynamically on dltest_ItemDataBound, I am binding the data, repopulating the check box every thing i am doing which is done very well, Now i am calling this ascx file on one aspx page say case.aspx, it that i have written the following code\[code\]private void GetModalities() { List<ListItem> lstRadiograph = new List<ListItem>(); DataSet ds2 = objGetBaseCase.GetSubspecialities(); ListItem list; MultipleModalitySelect1.DataSource = listItem; Pathophysiology.DataSource = objGetBaseCase.Pathophysiology(); list = new ListItem(); list.Text = "No add'l categories"; list.Value = http://stackoverflow.com/questions/6343521/0.ToString(); SublistItem.Add(list); for (int i = 0; i < ds2.Tables[0].Rows.Count; i++) { list = new ListItem(); list.Text = ds2.Tables[0].Rows[1].ToString(); list.Value = ds2.Tables[0].Rows[0].ToString(); SublistItem.Add(list); } Subspecialities.DataSource = SublistItem; }protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { GetModalities(); }}\[/code\]in this case.aspx page i have a text box\[code\]<asp:TextBox ID="txtAge" runat="server" class="inputgb" Width="30px" MaxLength="3"></asp:TextBox><asp:Label ID="lblAgeErr" runat="server" ForeColor="Red" Font-Bold="True" Font-Size="X-Large" Visible="False">*</asp:Label>\[/code\]i am validating the text box by condition\[code\]if (txtAge.Text == "") { lblAgeErr.Visible = true; error = true;} else { lblAgeErr.Visible = false;}\[/code\]THE PROBLEM ISif am txtAge is empty then condition is causing, but Modality is populating empty on !IsPostBack and showing empty check boxs, and if i am calling GetModality(); out of !IsPostBack then condition is causing well checkbox is not populating but when i am selecting some value then it is not getting selected.i am unable to find out what to do. so when txtAge is empty then checkbox should not populate empty when i write the GetModality() in inside the !IsPostBack when i should click on btn Next
 
Top