在前台我添加了GridView控件,代码如下:
<asp:GridView ID="MyGridView1" runat="server" AllowPaging="True"
AutoGenerateColumns="False" Width="100%" DataKeyNames="UserID"
OnPageIndexChanging="MyGrid_Page" Height="100%" OnRowEditing="MyGrid_edit" OnRowDeleted="MyGrid_delete">
<Columns>
<asp:BoundField DataField="UserID" HeaderText="用户编号" /> <asp:BoundField DataField="UserName" HeaderText="用户姓名" /> <asp:BoundField DataField="UserPassword" HeaderText="用户密码" /> <asp:BoundField DataField="NoAdmin" HeaderText="管理权限" /> <asp:CommandField ShowEditButton="True" />
<asp:CommandField ShowDeleteButton="True"/>
</Columns>
</asp:GridView>
要处理编辑事件,我在后台添加了如下代码:
public void MyGrid_edit(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
{
MyGridView1.EditIndex =(int)e.editIndex;
BindGrid();
}
出现了错误,“System.Web.UI.WebControls.GridViewCommandEventArgs”并不包含“editIndex”的定义,根本没editIndex这个方法,但是在网上很多都是这样介绍的,请问该怎么解决这个问题
<asp:GridView ID="MyGridView1" runat="server" AllowPaging="True"
AutoGenerateColumns="False" Width="100%" DataKeyNames="UserID"
OnPageIndexChanging="MyGrid_Page" Height="100%" OnRowEditing="MyGrid_edit" OnRowDeleted="MyGrid_delete">
<Columns>
<asp:BoundField DataField="UserID" HeaderText="用户编号" /> <asp:BoundField DataField="UserName" HeaderText="用户姓名" /> <asp:BoundField DataField="UserPassword" HeaderText="用户密码" /> <asp:BoundField DataField="NoAdmin" HeaderText="管理权限" /> <asp:CommandField ShowEditButton="True" />
<asp:CommandField ShowDeleteButton="True"/>
</Columns>
</asp:GridView>
要处理编辑事件,我在后台添加了如下代码:
public void MyGrid_edit(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
{
MyGridView1.EditIndex =(int)e.editIndex;
BindGrid();
}
出现了错误,“System.Web.UI.WebControls.GridViewCommandEventArgs”并不包含“editIndex”的定义,根本没editIndex这个方法,但是在网上很多都是这样介绍的,请问该怎么解决这个问题
protected void MyGrid_edit(object sender, GridViewEditEventArgs e)
{
MyGridView1.EditIndex = (int)e.NewEditIndex;
BindGrid(); }