获取gridview rowUpdating事件中单元格的新值

时间:2015-09-04 09:14:36

标签: c# asp.net

我想在gridview rowUpdating事件中获取单元格的新值:

这是我的代码:

<asp:GridView ID="gvRoles" DataKeyNames="RoleId" runat="server" 
    AutoGenerateColumns="False" GridLines="Vertical" CssClass="table 
    table-striped table-bordered" AutoGenerateEditButton="True" 
    OnRowCancelingEdit="gvRoles_RowCancelingEdit" OnRowUpdating="gvRoles_RowUpdating" 
    OnRowEditing="gvRoles_RowEditing">
    <Columns>
        <asp:BoundField DataField="RoleId" HeaderText="RoleId" ReadOnly="True" />
        <asp:BoundField DataField="RoleName" HeaderText="RoleName" ReadOnly="false" />
        <asp:BoundField DataField="Role_Description"  HeaderText="Role Description"  ReadOnly="false" />

    </Columns>
</asp:GridView>



protected void gvRoles_RowUpdating(object sender, GridViewUpdateEventArgs e)
{    
  GridViewRow row = gvRoles.Rows[e.RowIndex];
  TextBox txtBox= (TextBox)(row.Cells[1].Controls[0]);
  String str = txtBox.Text;

}

0 个答案:

没有答案