Error is showing
Object reference not set to an instance of an object.
at rdb5.SelectedValue = "1" and going to catch block. Data is coming right and going inside the loop but error is showing at rdb5.SelectedValue = "1".
RadioButtonList rdb5 = (RadioButtonList)e.Row.FindControl("rdb5");
RadioButtonList rdb6 = (RadioButtonList)e.Row.FindControl("rdb6");
RadioButtonList rdb7 = (RadioButtonList)e.Row.FindControl("rdb7");
using (SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["ConStr1"]))
{
string sql = "select * from RateSchedule ";
SqlCommand cmd = new SqlCommand(sql, con);
SqlDataAdapter adpt = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adpt.Fill(ds);
string s = ds.Tables[0].Rows[0]["RegularLabor"].ToString().Trim();
if (ds.Tables[0].Rows[0]["TaskType"].ToString() == "Default")
{
}
if (ds.Tables[0].Rows[0]["RegularLabor"].ToString().Trim() == "True")
{
rdb5.SelectedValue = "1";
//Here it is showing error "Object reference not set to an instance of an object."
}
else
{
rdb5.SelectedValue = "2";
}