skip to Main Content
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();

2

Answers


  1. Cell with index 1 probably won’t exist. Check your grid again.

    Login or Signup to reply.
  2. 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()
    
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search