Last post Aug 22, 2018 01:04 AM by muhdamean
Aug 10, 2018 08:50 AM|JagjitSingh|LINK
I have below code . On below line it gives above error. In item.text it shows value
CheckBoxList chkBoxList0 = (e.Row.FindControl("chkBoxList") as CheckBoxList);
using (SqlConnection con = new SqlConnection(CommonFunction.connectionString))
SqlCommand cmd = new SqlCommand("Select Loc from [Location]", con);
cmd.CommandType = CommandType.Text;
using (SqlDataReader sdr = cmd.ExecuteReader())
ListItem item = new ListItem();
item.Text = sdr["Loc"].ToString();
Aug 10, 2018 09:01 AM|PatriceSc|LINK
chkBoxList0 is likely null. Your control is perhaps named "chkBoxList0" as well rather than just "chkBoxList" ?
Aug 10, 2018 09:08 AM|oned_gk|LINK
Ensure it's datarow
Aug 13, 2018 07:23 AM|Brando ZWZ|LINK
According to your description, I couldn't directly find the reason why the it shows the Object reference not set to an instance of the object error.
Could you please post more details codes about the which method you used to add the item and the girdview html makeup? E.g onrowdatabound
If you could post more details information. it will be more easily for us to reproduce the issue and find the solution.
Aug 14, 2018 09:20 AM|rajesh93180|LINK
Please post your HTML. It seems your checkbox id is spelt wrong.
Aug 22, 2018 01:04 AM|muhdamean|LINK