In GridViewEdit_Update_Delete.aspx file

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GridViewEdit_Update_Delete.aspx.cs" Inherits="GridViewEdit_Update_Delete" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
       <asp:GridView ID="gvStudents" runat="server" AutoGenerateColumns="false" AutoGenerateEditButton="true"
        AutoGenerateDeleteButton="true" onrowediting="gvStudents_RowEditing" 
            onrowcancelingedit="gvStudents_RowCancelingEdit" 
            onrowdeleting="gvStudents_RowDeleting" onrowupdating="gvStudents_RowUpdating">
        <Columns>
          <asp:TemplateField HeaderText="student id" HeaderStyle-BackColor="Green">
            <ItemTemplate>
              <asp:Label ID="lblSid" runat="server" Text='<%#Eval("sid") %>' ></asp:Label>
            </ItemTemplate>
          </asp:TemplateField>
          <asp:TemplateField HeaderText="stu name" HeaderStyle-BackColor="Red" HeaderStyle-ForeColor="White">
            <ItemTemplate>
              <asp:Label ID="lblName" runat="server" Text='<%#Eval("name")%>'></asp:Label>
            </ItemTemplate>
            <EditItemTemplate>
              <asp:TextBox ID="tbName" runat="server" Text='<%#Eval("name") %>'></asp:TextBox>
            </EditItemTemplate>
          </asp:TemplateField>
          <asp:TemplateField HeaderText="stu dentclass" HeaderStyle-BackColor="blue" HeaderStyle-ForeColor="White">
            <ItemTemplate>
              <asp:Label ID="lblClass" runat="server" Text='<%#Eval("class")%>'></asp:Label>
            </ItemTemplate>
            <EditItemTemplate>
              <asp:TextBox ID="tbClass" runat="server" Text='<%#Eval("class") %>'></asp:TextBox>
            </EditItemTemplate>
          </asp:TemplateField>
        </Columns>
       </asp:GridView>
    </div>
    </form>
</body>
</html>

In GridViewEdit_Update_Delete.aspx.cx

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;

public partial class GridViewEdit_Update_Delete : System.Web.UI.Page
{
    string scn = ConfigurationManager.ConnectionStrings["sqlcns"].ConnectionString;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            FillStudentsInfo();
        }
    }
    private void FillStudentsInfo()
    {
        SqlConnection cn = new SqlConnection(scn);
        string qry = "select * from students";
        SqlCommand cmd = new SqlCommand(qry, cn);
        DataSet ds = new DataSet();
        SqlDataAdapter da = new SqlDataAdapter();
        da.SelectCommand = cmd;
        da.Fill(ds);
        DataTable dt = ds.Tables[0];
        gvStudents.DataSource = dt;
        gvStudents.DataBind();
        Session["ds"] = ds;
    }
    protected void gvStudents_RowEditing(object sender, GridViewEditEventArgs e)
    {
        int rowNum=e.NewEditIndex;
        gvStudents.EditIndex = rowNum;
        DataSet ds = (DataSet)Session["ds"];
        DataTable dt = ds.Tables[0];
        gvStudents.DataSource = dt;
        gvStudents.DataBind();
    }
    protected void gvStudents_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
        
        gvStudents.EditIndex = -1;
        DataSet ds = (DataSet)Session["ds"];
        gvStudents.DataSource = ds.Tables[0];
        gvStudents.DataBind();
        e.Cancel = true;
    }
    protected void gvStudents_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        GridViewRow gvr = gvStudents.Rows[e.RowIndex];
        Label lblSid = gvr.FindControl("lblSid") as Label;
        TextBox tbName = gvr.FindControl("tbName") as TextBox;
        TextBox tbClass = gvr.FindControl("tbClass") as TextBox;
        int sid = Convert.ToInt32(lblSid.Text);
        string sname = tbName.Text;
        string sclass=tbClass.Text;
        SqlConnection cn = new SqlConnection(scn);
        string qry = "updatestudents";
        SqlCommand cmd = new SqlCommand(qry, cn);
        cmd.CommandType = CommandType.StoredProcedure;
        SqlParameter p1 = new SqlParameter("@name", SqlDbType.VarChar, 40);
        SqlParameter p2 = new SqlParameter("@class", SqlDbType.VarChar,40);
        SqlParameter p3 = new SqlParameter("@sid", SqlDbType.Int);
        p1.Value = sname;
        p2.Value = sclass;
        p3.Value = sid;
        cmd.Parameters.Add(p1);
        cmd.Parameters.Add(p2);
        cmd.Parameters.Add(p3);
        cn.Open();
        cmd.ExecuteNonQuery();
        cn.Close();
        gvStudents.EditIndex = -1;
        e.Cancel = true;
        FillStudentsInfo();
    }
    protected void gvStudents_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        GridViewRow gvr = gvStudents.Rows[e.RowIndex];
        Label lblSid = gvr.FindControl("lblSid") as Label;
        SqlConnection cn = new SqlConnection(scn);
        string qry = "deletestudents";
        SqlCommand cmd = new SqlCommand(qry, cn);
        cmd.CommandType = CommandType.StoredProcedure;
        SqlParameter p1 = new SqlParameter("@sid", SqlDbType.Int);
        p1.Value = Convert.ToInt32(lblSid.Text);
        cmd.Parameters.Add(p1);
        cn.Open();
        cmd.ExecuteNonQuery();
        cn.Close();
        FillStudentsInfo();
    }
}

In web.config file:

<connectionStrings>
    <add name="sqlcns" connectionString="data source=admin-pc\sqlexpress; initial catalog=db24_25;integrated security=sspi" />
  </connectionStrings>

Delete Stored Procedures:

create proc deletestudents
(
   @sid int
)
as
begin
 delete students where sid=@sid;
end

Update stored procedure:

create proc updatestudents
(
   @sid int, @name varchar(40),@class varchar(40)
)
as
begin
 update students set name=@name,class=@class where sid=@sid;
end

Data base table structure:

students table