int index = Convert.ToInt32(e.CommandArgument); var id = ((Label)GridView1.Rows[index].FindControl("lblid")).Text.Trim(); // in this line SqlConnection con = new SqlConnection(connstring); string qry = "Delete from ['ISB VAS Nodes$'] where ID = " + id + ""; SqlCommand com = new SqlCommand(qry, con); // open connection con.Open(); int numberDeleted = com.ExecuteNonQuery(); if (numberDeleted > 0) { Label2.Text = "Deleted"; binddata(); } else { Label2.Text = "Not Deleted"; } // close connection con.Close(); } catch (System.Data.SqlClient.SqlException ex) { string msg = "Insert/Update Error:"; msg += ex.Message; throw new Exception(msg); } }
if(((Label)GridView1.Rows[index].FindControl("lblid"))!=null) { }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)