ASP.NET - problem in dynamically populating checkboxlist
Asked By shah zeb on 30-Dec-11 05:28 AM
i have dynamically populated checkboxlist control on selectedIndexChange of dropdownlist.
Below is the code for that.
The problem is when i re-call i.e., (when the selectedIndexChange of dropdownlist is called again) it appends the newly items with the existing data. i mean if "a" and "b" was the previous result. and on the new selectedIndexchange the result "c" and "d". The checkboxlist shows all four results.
If i do
then it solves my problem but creates another. i.e., i losses the id on selected Checkboxes.
If i create another checkboxlist. and add it to placeholder.
it also solves the problem but in that case i how can i generate the selectedIndexChange of checkboxlist
Kindly give suggestion...
below is the code
protected override void OnInit(EventArgs e)
///Load Track Function
public void loadTracks()
ConfigurationDB objConfig = new ConfigurationDB();
DataSet ds = objConfig.GetID(Convert.ToInt32(ddl.SelectedValue.ToString()));
for (int i = 0; i < ds.Tables.Rows.Count; i++)
CbxList.Items.Add(new ListItem(ds.Tables.Rows[i]["Name"].ToString(), ds.Tables.Rows[i]["ID"].ToString()));