更新行事件未返回更新值代码有什么问题?

时间:2017-02-09 12:15:53

标签: asp.net c#-4.0 webforms

<asp:GridView ID="GridView1" runat="server" Width="593px" AllowPaging="true" autogenerateeditbutton="true" 
         autogeneratecolumns="false" OnRowEditing="GridView1_RowEditing" OnRowCancelingEdit="GridView1_RowCancelingEdit"
         OnRowUpdating="GridView1_RowUpdating" DataKeyNames="Id">
            <columns>
            <asp:boundfield datafield="Id" visible="false" headertext="Id"/>
            <asp:boundfield datafield="Date" readonly="true" headertext="Date"/>
            <asp:boundfield datafield="OperationalHours"  headertext="OperationalHours"/>
            <asp:boundfield datafield="Description"  headertext="Description"/>
            </columns>
        </asp:GridView>

这是事件,它将返回先前的值,它不会返回更新的行。

 protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            int id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value.ToString());
            GridViewRow row = GridView1.Rows[e.RowIndex];

            string value = e.NewValues["OperationalHours"].ToString();

            TextBox textaddd = (TextBox)row.Cells[3].Controls[0];
            TextBox textadddd = (TextBox)row.Cells[4].Controls[0];
        }

0 个答案:

没有答案