Cant understand the error .. i am refering this link of gridview for my requirment For DetailsView
what is the mistak .. ???
Error 18 'System.Web.UI.WebControls.DetailsView' does not contain a definition for 'Cells'
and no extension method 'Cells' accepting a first argument of type
'System.Web.UI.WebControls.DetailsView' could be found (are you missing a using directive
or an assembly reference?)
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
LoadData();
}
}
private void LoadData()
{
string query = @"SELECT ID,Name,Emp_No,Job_Title,Nationality,Administration,Section,Another_job,health_no,Exp_Date,National_ID,serial_no,reference,confirm_rcrd,arabic_name,arabic_jobtitle FROM KSMCemp_data";
SqlDataAdapter da = new SqlDataAdapter(query, con);
DataTable table = new DataTable();
da.Fill(table);
GridView2.DataSource = table;
GridView2.DataBind();
}
public void chkStatus_OnCheckedChanged(object sender, EventArgs e)
{
CheckBox chkStatus = (CheckBox)sender;
DetailsView row = (DetailsView)chkStatus.NamingContainer;
string cid = row.Cells[1].Text; <<--- ERROR
bool status = chkStatus.Checked;
string query = "UPDATE KSMCemp_data SET confirm_rcrd = @confirm_rcrd WHERE ID = @ID";
SqlCommand com = new SqlCommand(query, con);
com.Parameters.Add("@confirm_rcrd", SqlDbType.Bit).Value = status;
com.Parameters.Add("@ID", SqlDbType.Int).Value = cid;
con.Open();
com.ExecuteNonQuery();
con.Close();
LoadData();
}
http://www.ezzylearning.com/tutorial.aspx?tid=5187857&q=using-checkbox-in-asp-net-gridview-control