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 GPosted Dec 12, 2016, 11:13 PM
"));
Chriz LPosted Dec 13, 2016, 1:53 AM
Prakash KumarPosted Dec 12, 2016, 10:44 PM
Chriz LPosted Dec 12, 2016, 8:45 AM
Brijesh RathorPosted Dec 12, 2016, 8:07 AM
Manas MohapatraPosted Dec 12, 2016, 7:54 AM