Hi all,
I am creating a checkbox dynamically on page load.
using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SimplifyNew"].ToString()))
{
SqlCommand cmd = new SqlCommand("usp_selectModifiedResults", conn);
cmd.CommandType = CommandType.StoredProcedure;
conn.Open();
SqlDataReader reader1 = cmd.ExecuteReader();
while( reader1.Read())
{
System.Web.UI.HtmlControls.HtmlGenericControl DivCheck = new System.Web.UI.HtmlControls.HtmlGenericControl("DIV");
DivCheck.Style.Add("float","left");
CheckBox cb = new CheckBox();
DivCheck.Controls.Add(cb);
bradbandPanelTarget.Controls.Add(DivCheck);
cb.ID = reader1["Id"].ToString();
cb.Text = reader1["LabelName"].ToString();
}
reader1.Close();
conn.Close();
}
once the page loads with all the checkbox, we check the desired checkboxes and then on click of a button, the values should get submitted.
How can i access those checkboxes in button click event and how can i know which check boxes are clicked?
PS: I cant use if (chkSpeed2MB.Checked) in my application. i have to do coding in such a way...that even if more fields are added in the database i neednt add more lines of code