How to create number of checkboxs according to database
how to create number of checkbox according to no of data present in database and checkbox text will comes from the data present in database dynamically
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
PradeepRank #6,279 · 271 reputationPosted Sep 4, 2015, 2:32 AM EDT
con.Open();
str = "select * from tableName";
com = new SqlCommand(str, con);
sqlda = new SqlDataAdapter(com);
DataTable dt = new DataTable();
sqlda.Fill(dt);
if (dt.Rows.Count - 1 > 0)
{
CheckBoxList1.DataSource = dt;
CheckBoxList1.DataTextField = "items";
CheckBoxList1.DataValueField = "id";
CheckBoxList1.DataBind();
}
con.Close();
Susanta RoutRank #1,557 · 1K reputationPosted Sep 4, 2015, 2:39 AM EDT
PradeepRank #6,279 · 271 reputationPosted Sep 4, 2015, 4:12 AM EDT
Susanta RoutRank #1,557 · 1K reputationPosted Sep 4, 2015, 4:57 AM EDT
PradeepRank #6,279 · 271 reputationPosted Sep 6, 2015, 9:50 PM EDT
for (int j = 1; j <= 10; j++)
{
plhCategory.Controls.Add(new LiteralControl("
for (int i = 0; i < 10; i++)
{
plhCategory.Controls.Add(new LiteralControl("" + i.ToString() + ""));
}
plhCategory.Controls.Add(new LiteralControl("
}
Susanta RoutRank #1,557 · 1K reputationPosted Sep 6, 2015, 10:01 PM EDT
PradeepRank #6,279 · 271 reputationPosted Sep 6, 2015, 10:08 PM EDT
Susanta RoutRank #1,557 · 1K reputationPosted Sep 6, 2015, 10:12 PM EDT