string user = string.Empty;
string constr = ConfigurationManager.ConnectionStrings["StatusConnectionString"].ConnectionString;
SqlConnection con = new SqlConnection(constr);
string result = "SELECT [UserID],[Status] FROM [MSCAssignment].[dbo].[StatusButton] WHERE [Status]='1'";
con.Open();
SqlCommand showresult = new SqlCommand(result, con);
SqlDataReader rd = showresult.ExecuteReader();
//string dd = rd["UserID"].ToString();
CheckBoxList chkbx = (CheckBoxList)FindControl("UserID");
//ListItem currentCheckBox = chkbx.Items.FindByValue(rd["UserID"].ToString());
for (int i = 0; i < chkbx.Items.Count; i++)
{
if (chkbx.Items[i].Selected)
{
user = chkbx.Items[i].Value = ";";
}
}
Asked
Active
Viewed 30 times
0

John Wu
- 50,556
- 8
- 44
- 80

nyein winhtwe
- 21
- 2
-
It'd be helpful to know what line this exception is thrown on – Tah Sep 03 '16 at 04:30
1 Answers
0
This line would throw the error if the connection string was not found:
string constr = ConfigurationManager.ConnectionStrings["StatusConnectionString"].ConnectionString;
This will throw the error if the control doesnt' exist:
CheckBoxList chkbx = (CheckBoxList)FindControl("UserID");

John Wu
- 50,556
- 8
- 44
- 80