Try this,
Add event on_click in linkbutton, see below.
<EditItemTemplate>
<asp:LinkButton ID="lnkUpdate" runat="server" Text="Update" CommandName="Update" onclick="lnkUpdate_click" />
<asp:LinkButton ID="lnkCancel" runat="server" Text="Cancel" CommandName="Cancel" />
</EditItemTemplate>
Then add new void in behind code
protected void lnkUpdate_Click(object sender, EventArgs e)
{
var autoID = GridView1.DataKeys[e.RowIndex].Value;
GridViewRow row = GridView1.Rows[e.RowIndex] as GridViewRow;
TextBox tVideo= row.FindControl("txtName") as TextBox;
using (SqlConnection conn = new SqlConnection(ConnString))
{
string sql = "Update VIDEO set Video_Name = @Video_Name WHERE Video_Number = @Video_Number";
using (SqlCommand cmd = new SqlCommand(sql, conn))
{
cmd.Parameters.AddWithValue("@Video_Name", tVideo.Text.Trim());
cmd.Parameters.AddWithValue("@Video_Number", autoID);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
}
lblMessage.Text = "Record updated sussesfully!";
GridView1.EditIndex = -1;
this.PopulateData();
}
Regards,
Alexander Andri