Click here to Skip to main content
15,885,839 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Friends, I'm facing problem in a very basic area of gridview. I'm using a Gridview to display records and then have Edit option for each row. I'm not using any control inside gridview, directly values are there.

Now, when user clicks update button in edit mode, not getting updated value from any columns of gridview. Gridview structure is like:
C#
<asp:GridView ID="gvTime" runat="server" AutoGenerateEditButton="True" 
                    AutoGenerateColumns="True" CellPadding="1" CellSpacing="1" 
                    onrowcancelingedit="gvTime_RowCancelingEdit" onrowediting="gvTime_RowEditing" 
                    onrowupdating="gvTime_RowUpdating">
                    <RowStyle HorizontalAlign="Center" />
                    <HeaderStyle HorizontalAlign="Center" />
                    <EditRowStyle BackColor="#CCFFCC" ForeColor="Maroon" HorizontalAlign="Center" />
                </asp:GridView>

Now, in Rowupdating event, it's like :
<pre lang="c#">
 protected void gvTime_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
int index = int.Parse(Session["Index"].ToString())+1;
GridViewRow row = gvTime.Rows[index];
string overtime = e.NewValues[0].ToString();
gvTime.EditIndex = -1;
BindData();


Here string overtime is always showing olddata, never can pull new data entered by user. I want to manually call SQLCommand to update database based on this updated value from the above function. Please give me some solution.
Posted
Updated 27-Aug-12 4:56am
v2

1 solution

C#
 protected void gvTime_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
int index = e.RowIndex;
GridViewRow row = gvTime.Rows[index];
//Call your update statement here!
UpdateData(ID); //Something like this
BindData();


Hope it helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900