I have a GridView
with several Textboxs
in Footer
, this to try to insert, but at the moment of clicking the button, it fails and tells me that the statement .
I'm using as a BD test one in access
my code is the following since the finished update, does not insert but does not show syntax error or anything like that
protected void dataGridView1_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
Button bt = (Button)sender;
GridViewRow grdRow = (GridViewRow)bt.Parent.Parent;
TextBox Txt_who = (TextBox)grdRow.Cells[0].FindControl("Txt_who");
int Txt_pay_roll = Convert.ToInt32(grdRow.Cells[1].FindControl("Txt_pay_roll"));
TextBox Txt_name = (TextBox)grdRow.Cells[2].FindControl("Txt_name");
TextBox Txt_ou = (TextBox)grdRow.Cells[3].FindControl("Txt_ou");
int Txt_pool = Convert.ToInt32(grdRow.Cells[4].FindControl("Txt_pool"));
int Txt_team = Convert.ToInt32(grdRow.Cells[5].FindControl("Txt_team"));
int Txt_rol = Convert.ToInt32(grdRow.Cells[6].FindControl("Txt_rol"));
using (OleDbConnection connection = new OleDbConnection())
{
using (OleDbCommand command = new OleDbCommand("SELECT * FROM users"))
{
command.Connection = connection;
connection.Open();
command.CommandText = "INSERT INTO users (who, payroll_number, ou, pool, team, rol_id) VALUES (@WHO, @PAYROLL_NUMBER, @NAME, @OU, @POOL @TEAM, @ROL_ID)";
command.Parameters.AddWithValue("@WHO", Txt_who.Text.Trim());
command.Parameters.AddWithValue("@PAYROLL_NAME", Txt_who.Text.Trim());
command.Parameters.AddWithValue("@OU", Txt_who.Text.Trim());
command.Parameters.AddWithValue("@POOL", Txt_who.Text.Trim());
command.Parameters.AddWithValue("@TEAM", Txt_who.Text.Trim());
command.Parameters.AddWithValue("@ROL_ID", Txt_who.Text.Trim());
command.ExecuteNonQuery();
}
}
}
catch (Exception)
{
}
}
and the error that marks me is the following
Invalid postback or callback argument. Event validation is enabled using 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.