问题描述
后台代码:protectedvoidgvCustomres_RowEditing(objectsender,GridViewEditEventArgse){this.gvCustomres.EditIndex=e.NewEditIndex;stringID=this.gvCustomres.DataKeys[e.NewEditIndex].Values["ID"].ToString();Response.Redirect("ShopEdit.aspx?id="+ID);}protectedvoidgvCustomres_RowDeleting(objectsender,GridViewDeleteEventArgse){Response.Redirect("ShopEdit.aspx?id=");}前台:<asp:GridViewID="gvCustomres"runat="server"AutoGenerateColumns="False"GridLines="None"AllowPaging="True"CssClass="mGrid"PagerStyle-CssClass="pgr"AlternatingRowStyle-CssClass="alt"onrowdatabound="gvCustomres_RowDataBound"DataKeyNames="ID"onrowdeleting="gvCustomres_RowDeleting"onrowediting="gvCustomres_RowEditing"><AlternatingRowStyleCssClass="alt"></AlternatingRowStyle><Columns><asp:BoundFieldDataField="mItemName"HeaderText="商品名称"><ItemStyleWidth="30%"/></asp:BoundField><asp:BoundFieldDataField="mModel"HeaderText="型号"/><asp:BoundFieldDataField="mBrand"HeaderText="品牌名称"><ItemStyleHorizontalAlign="Center"Width="20%"/></asp:BoundField><asp:BoundFieldDataField="mPrice"HeaderText="价格"><ItemStyleHorizontalAlign="Center"Width="10%"/></asp:BoundField><asp:BoundFieldDataField="mStockqty"HeaderText="库存"><ItemStyleHorizontalAlign="Center"Width="10%"/></asp:BoundField><asp:BoundFieldDataField="mTcategory"HeaderText="类别"><ItemStyleHorizontalAlign="Center"Width="10%"/></asp:BoundField><asp:CommandFieldShowEditButton="True"HeaderText="操作"ShowDeleteButton="True"><ItemStyleHorizontalAlign="Center"Width="10%"/></asp:CommandField></Columns><PagerStyleCssClass="pgr"></PagerStyle></asp:GridView>