entered values not getting in code
<p>I am trying to learn ASPX and am doing a web site (studying purpose)</p>

<p>I have an employee list in grid view when a name in the list is clicked I must pass the value to db and display the details in a separate page.
I did this by using this piece of code</p>

<pre><code>LinkButton lnkCustomerID = sender as LinkButton;
string strCustomerID = lnkCustomerID.CommandArgument;
Response.Redirect("EmployeeDetail.aspx?Parameter=" + strCustomerID);
</code></pre>

<p>It worked fine. </p>

<p>In the detail page i am showing the details in another grid and I did this using the code below</p>

<pre><code> SqlCommand cmdCustomerDetails = new SqlCommand("GetEmployee", sqlConnect);
             cmdCustomerDetails.CommandType = CommandType.StoredProcedure;
             cmdCustomerDetails.Parameters.AddWithValue("@ID", employeeId);
             if (sqlConnect.State == ConnectionState.Closed)
                 sqlConnect.Open();
             //Create DataReader to read the record
             SqlDataReader dReader = cmdCustomerDetails.ExecuteReader();
             GridView2.DataSource = dReader;
             GridView2.DataBind();
             sqlConnect.Close();
</code></pre>

<p>It worked also, but when I try to update values by clicking the Update Button which is an Item Template as shown</p>

<pre><code>&lt;asp:GridView ID="GridView2" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None"
        AutoGenerateColumns="False"&gt;
        &lt;Columns&gt;
            &lt;asp:TemplateField HeaderText="Name"&gt;
                &lt;ItemTemplate&gt;
                    &lt;asp:TextBox ID="txtName" runat="server" Text='&lt;%# Eval("name")%&gt;'&gt;&lt;/asp:TextBox&gt;
                    &lt;asp:RequiredFieldValidator ID="rqdfldName" runat="server" ErrorMessage="Name Cannot Be Empty"
                        ViewStateMode="Disabled" ControlToValidate="txtName" ValidationGroup="Update"&gt;&lt;/asp:RequiredFieldValidator&gt;
                &lt;/ItemTemplate&gt;
            &lt;/asp:TemplateField&gt;
            &lt;asp:TemplateField HeaderText="Age"&gt;
                &lt;ItemTemplate&gt;
                    &lt;asp:TextBox ID="txtAge" runat="server" Text='&lt;%# Eval("age")%&gt;'&gt;&lt;/asp:TextBox&gt;
                &lt;/ItemTemplate&gt;
            &lt;/asp:TemplateField&gt;
            &lt;asp:TemplateField HeaderText="Address"&gt;
                &lt;ItemTemplate&gt;
                    &lt;asp:TextBox TextMode="MultiLine" ID="txtAddress" runat="server" Text='&lt;%# Eval("address")%&gt;'&gt;&lt;/asp:TextBox&gt;
                &lt;/ItemTemplate&gt;
            &lt;/asp:TemplateField&gt;
            &lt;asp:TemplateField&gt;
                &lt;ItemTemplate&gt;
                    &lt;asp:Button ID="btnUpdate" runat="server" Text="Update" ValidationGroup="Update"
                        CommandArgument='&lt;%#Eval("id") %&gt;' OnClick="btnUpdate_Click" /&gt;
                &lt;/ItemTemplate&gt;
            &lt;/asp:TemplateField&gt;
        &lt;/Columns&gt;
        &lt;AlternatingRowStyle BackColor="White" /&gt;
        &lt;EditRowStyle BackColor="#7C6F57" /&gt;
        &lt;FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /&gt;
        &lt;HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /&gt;
        &lt;PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" /&gt;
        &lt;RowStyle BackColor="#E3EAEB" /&gt;
        &lt;SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" /&gt;
        &lt;SortedAscendingCellStyle BackColor="#F8FAFA" /&gt;
        &lt;SortedAscendingHeaderStyle BackColor="#246B61" /&gt;
        &lt;SortedDescendingCellStyle BackColor="#D4DFE1" /&gt;
        &lt;SortedDescendingHeaderStyle BackColor="#15524A" /&gt;
    &lt;/asp:GridView&gt;
</code></pre>

<p>I am getting this error</p>

<p>Invalid postback or callback argument.  Event validation is enabled using  in configuration or &lt;%@ 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.</p>

<p>Can anyone please help me out</p>

<p>I was able to overcome that error by setting the property of that page to false
like this</p>

<pre><code>&lt;%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" EnableEventValidation="false" AutoEventWireup="true" CodeFile="EmployeeDetail.aspx.cs" Inherits="EmployeeDetail" %&gt;
</code></pre>

<p>But when I click the update button and find the values of the controls I am not getting updated values</p>

<pre><code>int empID;
        string age, address, name;
        Button btnUpdateUser = sender as Button;
        TextBox tbName, tbAge, tbAddress;
        SqlConnection sqlConnect;
        try
        {
            tbName = (TextBox)GridView2.Rows[0].FindControl("txtName");
            tbAge = (TextBox)GridView2.Rows[0].FindControl("txtAge");
            tbAddress = (TextBox)GridView2.Rows[0].FindControl("txtAddress");
            sqlConnect = new SqlConnection("server=WINNER-PC\\SQLEXPRESS;integrated security=true;initial catalog=Test");
            if (sqlConnect.State == ConnectionState.Closed)
                sqlConnect.Open();
            empID = Convert.ToInt32(btnUpdateUser.CommandArgument);
            name = tbName.Text;
            age = tbAge.Text;
            address = tbAddress.Text;
            SqlCommand sqlCommand = new SqlCommand("UpdateEmployee", sqlConnect);
            sqlCommand.CommandType = CommandType.StoredProcedure;
            sqlCommand.Parameters.AddWithValue("@ID", empID);
            sqlCommand.Parameters.AddWithValue("@Name", name);
            sqlCommand.Parameters.AddWithValue("@Age", age);
            sqlCommand.Parameters.AddWithValue("@Address", address);
            sqlCommand.ExecuteNonQuery();
            Response.Redirect("Employees.aspx", false);
        }
        catch (Exception ex)
        {
            throw ex;
        }
</code></pre>

<p>When both the grid view were in same page i was able to update , but when i moved the second grid to a new page updation is not working .. Please help me out</p>
