Hello,
I want to create dynamically checkboxes based on sproc result (one checkbox for each row).Here's my code:
- public void selectChecks(Label appno, Label Cat)
- {
- SqlConnection connection = getConnection();
- try
- {
- connection.Open();
- SqlCommand command = new SqlCommand("ChecksSelect", connection);
- command.CommandType = CommandType.StoredProcedure;
- command.Parameters.Add("@Appno", SqlDbType.Int).Value = Convert.ToInt32(appno.Text);
- command.Parameters.Add("@Cat", SqlDbType.Int).Value = Convert.ToInt32(Cat.Text);
- SqlDataAdapter adapter = new SqlDataAdapter(command);
- DataSet ds = new DataSet();
- adapter.Fill(ds);
- foreach (DataTable table in ds.Tables)
- {
- foreach (DataRow dr in table.Rows)
- {
- CheckBox check = new CheckBox();
- check.Text = dr["CheckDescr"].ToString();
- if (dr["CheckResult"].ToString() == "1")
- check.Checked = true;
- else
- check.Checked = false;
- check.ID = dr["CheckCode"].ToString() + "Lbl";
- }
- }
- }
- catch (Exception ex)
- { myMessageBox(ex.Message); }
- }
How can I place them in my form's table?
Thank you in advance.

Ananth GRank #1,176 · 1.5K reputationPosted Dec 12, 2016, 6:13 PM EST
"));
Manas MohapatraRank #182 · 13.2K reputationPosted Dec 12, 2016, 2:54 AM EST
Brijesh RathorRank #7,391 · 242 reputationPosted Dec 12, 2016, 3:07 AM EST
Chriz LRank #9,376 · 207 reputationPosted Dec 12, 2016, 3:45 AM EST
Prakash KumarRank #1,798 · 828 reputationPosted Dec 12, 2016, 5:44 PM EST
Chriz LRank #9,376 · 207 reputationPosted Dec 12, 2016, 8:53 PM EST