Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
เขียน code ลบ ที่หน้า.cs
Code (C#)
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Delete")
{
//*** CustomerID ***//
//Label Label3 = (Label)(e.Row.FindControl("Label3"));
Label Label3 = (Label)GridView1.FooterRow.FindControl("Label3");
MySqlConnection Conn = new MySqlConnection(StrConn);
string strSQL;
strSQL = "DELETE FROM fam WHERE id = '" + Label3 + "' ";
Conn.Open();
objCmd = new MySqlCommand(strSQL, Conn);
objCmd.ExecuteNonQuery();
}
ScriptManager.RegisterClientScriptBlock(this, typeof(Page), UniqueID, "alert('ลบข้อมูลเรียบร้อยแล้วค่ะ')", true);
BindData();
}