protected void lnkdelete_Click(object sender, EventArgs e) { LinkButton lnkbtndel = sender as LinkButton; GridViewRow gdrow = lnkbtndel.NamingContainer as GridViewRow; int rowIndex = gdrow.RowIndex; Label appointmentid = GridView1.Rows[rowIndex].FindControl("ID2") as Label; string appointmentid1 = appointmentid.Text; int appointmentid2 = Convert.ToInt32(appointmentid1); // int appointmentid = Convert.ToInt32(GridView1.DataKeys[gdrow.RowIndex].Value.ToString()); int result = obj.CancelAppointment(appointmentid2); if (result > 0) { binddata(); } else { } }