string cid = row.Cells[1].Text; // Error in this line
public void chkStatus_OnCheckedChanged(object sender, EventArgs e) { public void chkStatus_OnCheckedChanged(object sender, EventArgs e) { ASPxCheckBox chkStatus = (ASPxCheckBox)sender; GridViewDataRowTemplateContainer row = chkStatus.NamingContainer as GridViewDataRowTemplateContainer; string cid = row.Cells[1].Text; // Error in this line bool status = chkStatus.Checked; string constr = ConfigurationManager.ConnectionStrings["BuckshawHomesConnectionString"].ConnectionString; string query = "UPDATE [tblHouseImage] SET Active = @Approved WHERE HouseImageID = @HouseImageID"; SqlConnection con = new SqlConnection(constr); SqlCommand com = new SqlCommand(query, con); com.Parameters.AddWithValue("@Approved", status); com.Parameters.AddWithValue("@HouseImageID", cid); con.Open(); com.ExecuteNonQuery(); con.Close(); grid.DataBind(); } }
var chk = (CheckBox)sender; var row = (GridViewRow)chk.NamingContainer; var index = row.RowIndex; var str = gridview1.Rows[index].Cells[1].Text;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)