Like That How to get CheckBoxlist And RadioButton List in asp.net

Like That How to get CheckBoxlist And RadioButton List in asp.net

Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Amit MohantyRank #112 · 20K reputationPosted Mar 10, 2023, 6:37 AM EST
CheckBoxList control in ASP.NET:
To access the selected values of the CheckBoxList control in code-behind, you can use the below code.
RadioButtonList control in ASP.NET:
To access the selected value of the RadioButtonList control in code-behind, you can use the below code:
Naimish MakwanaRank #324 · 7.7K reputationPosted Mar 10, 2023, 3:04 AM EST
Hello Tarun,
Try this.
For CheckBoxList:
For RadioButtonList:
Thanks
Naimish Makwana
TarunRank #6,374 · 268 reputationPosted Mar 13, 2023, 3:34 AM EDT
Cascading DropdownList
if (DropDownList2.SelectedValue == "0") { DropDownList3.SelectedValue = "0"; DropDownList3.Enabled = false; } else { DropDownList3.Enabled = true; SqlParameter param = new SqlParameter("@sid", DropDownList2.SelectedValue); DataSet ds = new DataSet(); ds = GetData("usp_city_get", param); if (ds.Tables[0].Rows.Count > 0) { DropDownList3.DataSource = ds; DropDownList3.DataBind(); DropDownList3.Items.Insert(0, new ListItem("--select city--", "0")); } } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Fill_Country(); DropDownList2.Items.Insert(0, new ListItem("--select state--", "0")); DropDownList3.Items.Insert(0, new ListItem("--select city--", "0")); DropDownList2.Enabled = false; DropDownList3.Enabled = false; } } public void Fill_Country() { DataSet ds = new DataSet(); ds = GetData("usp_country_get", null); if (ds.Tables[0].Rows.Count > 0) { DropDownList1.DataSource = ds; DropDownList1.DataBind(); DropDownList1.Items.Insert(0, new ListItem("--select country--", "0")); } } private DataSet GetData(string SP_Name, SqlParameter param) { SqlDataAdapter da = new SqlDataAdapter(SP_Name, Con); da.SelectCommand.CommandType = CommandType.StoredProcedure; if (param != null) { da.SelectCommand.Parameters.Add(param); } DataSet ds = new DataSet(); da.Fill(ds); return ds; } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { if (DropDownList1.SelectedValue == "0") { DropDownList2.SelectedValue = "0"; DropDownList2.Enabled = false; } else { DropDownList2.Enabled = true; SqlParameter param = new SqlParameter("@cid", DropDownList1.SelectedValue); DataSet ds = new DataSet(); ds = GetData("usp_state_get", param); if (ds.Tables[0].Rows.Count > 0) { DropDownList2.DataSource = ds; DropDownList2.DataBind(); DropDownList2.Items.Insert(0, new ListItem("--select state--", "0")); } } DropDownList3.SelectedValue = "0"; DropDownList3.Enabled = false; }