Use onrowediting and onrowupdating in gridview markup...
some thing like 
  <asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" 
    GridLines="None" AllowPaging="true" AllowSorting="true" PageSize="5" DataKeyNames="Id"
    onpageindexchanging="GridView1_PageIndexChanging" 
    AutoGenerateEditButton="true" AutoGenerateDeleteButton="true"
    onsorting="GridView1_Sorting" onrowediting="GridView1_RowEditing">
EDIT:
Hey I am not very sure abt winforms, but in websites try this..
 protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
    //your code that will edit/update.
}
in general code with Sqlcommand and connection will be something like"
 SqlConnection con;
SqlCommand cmd;
DataSet ds;
SqlDataAdapter da;
 protected DataSet FillDataSet()
{
    string source = "Database=GridTest;Server=Localhost;Trusted_Connection=yes";
    con = new SqlConnection(source);
    cmd = new SqlCommand("proc_mygrid", con);
    ds = new DataSet();
    da = new SqlDataAdapter(cmd);
    da.Fill(ds);
    GridView1.DataSource = ds;
    GridView1.DataBind();
    return ds;
}
Hope this helps.