gridview not showing new updated values when rowupdating event is triggered
<p>am using a gridview. When I click on the edit button the update and cancel button appear. Upon modifying the values in textbox which come from EditItemTemplate , the new values dont show in the event handler rowupdating(), instead I get the values which appear when the page was rendered. How do I grab the new values from these textboxes and proceed further? Here is the code.</p>

<p>aspx page</p>

<pre><code>    &lt;%@ Page Language="C#" MasterPageFile="~/Master Pages/FacultyMasterpage.master" AutoEventWireup="true" CodeFile="FacultyQuestion.aspx.cs" Inherits="Faculty_FacultyQuestion" Title="Untitled Page" %&gt;

&lt;asp:Content ID="Content1" ContentPlaceHolderID="Content10" Runat="Server"&gt;
    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;asp:GridView ID="GridView1" runat="server" BackColor="White" 
        BorderColor="#CC9966" BorderStyle="None" BorderWidth="1px" CellPadding="4" 
        AllowPaging="True" AutoGenerateEditButton="True" 
        onrowcancelingedit="GridView1_RowCancelingEdit" 
        onrowediting="GridView1_RowEditing" onrowupdating="GridView1_RowUpdating"&gt;
        &lt;FooterStyle BackColor="#FFFFCC" ForeColor="#330099" /&gt;
        &lt;RowStyle BackColor="White" ForeColor="#330099" /&gt;
        &lt;PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" /&gt;
        &lt;SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" /&gt;
        &lt;HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" /&gt;
    &lt;/asp:GridView&gt;
    &lt;br /&gt;
&lt;/asp:Content&gt;
&lt;asp:Content ID="Content2" ContentPlaceHolderID="Content20" Runat="Server"&gt;
&lt;/asp:Content&gt;
</code></pre>

<p>cs file coading</p>

<pre><code>using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Faculty_FacultyQuestion : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindData();
        }
    }
    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        GridView1.EditIndex = e.NewEditIndex;
        BindData();
    }
    private void BindData()
    {
        DataTable dt = Class3.QuestionForFaculty(Convert.ToInt32(Session["rid"]));
        GridView1.DataSource = dt;
        GridView1.DataBind();

    }

    protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
        e.Cancel = true;
        GridView1.EditIndex = -1;
        BindData();
    }
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        {

                //Retrieve the table from the session object.

            DataTable dt = Class3.QuestionForFaculty(Convert.ToInt32(Session["rid"]));
            GridView1.DataSource = dt;
            GridView1.DataBind();

                //Update the values.
                GridViewRow row = GridView1.Rows[e.RowIndex];

                dt.Rows[row.DataItemIndex]["ans"] = ((TextBox)(row.Cells[2].Controls[0])).Text;

                GridView1.EditIndex = -1;
               BindData();
        }
    }
}
</code></pre>

<p>class 3 coading</p>

<pre><code>using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.ComponentModel;

[DataObject]
/// &lt;summary&gt;
/// Summary description for Class3
/// &lt;/summary&gt;
public class Class3
{

     private static string conn = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
    [DataObjectMethod(DataObjectMethodType.Select)]
    public static DataTable getall()
    {
        SqlDataAdapter dp = new SqlDataAdapter("Select * from Question", conn);
        DataSet ds = new DataSet();
        dp.Fill(ds, "Question");
        return ds.Tables["Question"];
    }
    [DataObjectMethod(DataObjectMethodType.Delete)]
    public static int delete(int qid)
    {
        SqlConnection con = new SqlConnection(conn);
        SqlCommand cmd = new SqlCommand("Delete into Question qid = @a", con);
        cmd.Parameters.Add("@a", SqlDbType.VarChar).Value = qid;

        con.Open();
        int i = cmd.ExecuteNonQuery();
        con.Close();
        return(i);

    }
     [DataObjectMethod(DataObjectMethodType.Select)]
    public static DataTable QuestionForFaculty(int rid)
    {
        SqlDataAdapter dp = new SqlDataAdapter("SELECT Question.question, Question.ans,Question.qid, Subject.subjectname, Question.posteddate, Registration.name, Registration.role, Registration.rid FROM Question INNER JOIN Registration ON Question.rid = Registration.rid INNER JOIN Subject ON Question.sid = Subject.subjectid WHERE (Question.fid = '"+rid+"')", conn);
        DataSet ds = new DataSet();
        dp.Fill(ds, "Question");
        return ds.Tables["Question"];
    }


}
</code></pre>
