int secilenıd = GridView1.SelectedIndex;
GridViewRow row = GridView1.Rows[secilenıd];
string sorgu = "DELETE FROM PersonelBilgileri WHERE PersonelID='" row.Cells[1].Text "'";
SqlCommand cmd = new SqlCommand();
CodePudding user response:
Cell with index 1 probably won't exist. Check your grid again.
CodePudding user response:
In Gridview Use datakeys in gridview control for better execution
<asp:GridView ID="GridView1" AllowPaging="false" AutoGenerateColumns="false" PagerStyle-Mode="NumericPages" DataKeyNames="datatableprimarykey"
OnSelectedIndexChanged="GridView1_SelectedIndexChanged" >
//c#
string PersonelID =this.GridView1.DataKeys[this.GridView1.SelectedIndex].Value.ToString()