protected void CategoryChkboxLst_SelectedIndexChanged(object sender, EventArgs e) { for (int i = 0; i < CategoryChkboxLst.Items.Count; i++) { if (CategoryChkboxLst.Items[i].Selected == true) { objdc.ItemID = Convert.ToInt32(CategoryChkboxLst.Items[i].Value); SubCategoryChkboxLst = new CheckBoxList(); SubCategoryChkboxLst.ID = "SubCategoryChkboxLst_" + objdc.ItemID; if (SubCategoryPnl.FindControl(SubCategoryChkboxLst.ID)!=null) { this.ViewState.Remove(SubCategoryChkboxLst.ID); SubCategoryPnl.Controls.Remove(SubCategoryPnl.FindControl(SubCategoryChkboxLst.ID)); myControlList.Remove(SubCategoryChkboxLst.ID); } DataTable dt = new DataTable(); dt = objbl.GetSubCategories(ref objdc); SubCategoryChkboxLst.DataSource = dt; SubCategoryChkboxLst.ID = "SubCategoryChkboxLst_" + objdc.ItemID; SubCategoryChkboxLst.DataTextField = "SUB_ITEM_NAME"; SubCategoryChkboxLst.DataValueField = "SUB_ITEM_ID"; SubCategoryChkboxLst.DataBind(); SubCategoryChkboxLst.RepeatColumns = 5; SubCategoryChkboxLst.RepeatDirection = RepeatDirection.Horizontal; //lblYear.ID = "lbl_" + li.Value; SubCategoryPnl.Controls.Add(SubCategoryChkboxLst); SubCategoryPnl.Controls.Add(new LiteralControl("<br>")); myControlList.Add(SubCategoryChkboxLst.ID); ViewState["myControlList"] = myControlList; } } }
protected override void LoadViewState(object savedState) { base.LoadViewState(savedState); myControlList = (List<string>)ViewState["myControlList"]; foreach (string ctlID in myControlList) { CheckBoxList cklt = new CheckBoxList(); cklt.ID = ctlID; LiteralControl lineBreak = new LiteralControl("<br />"); SubCategoryPnl.Controls.Add(cklt); SubCategoryPnl.Controls.Add(lineBreak); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)