Gridview 修改编辑并且转页面赋值

    技术2022-05-20  53

    1.在gridview中建模板

     <asp:TemplateField HeaderText="申述内容">                     <ItemTemplate>                   <asp:LinkButton ID="Linkbtn" runat="server"  CommandName="Update" CommandArgument='<%#Eval("Id") %>'> 申述内容</asp:LinkButton>                     </ItemTemplate>                 </asp:TemplateField> 

    给赋值为ID 绑定数值

    2.在Gridview的 RowCommand的事件中

      protected void grview_RowCommand(object sender, GridViewCommandEventArgs e)     {         string Cmd = e.CommandName;         int Id = Convert.ToInt32(e.CommandArgument);          if (Cmd == "Update")         {             Response.Redirect("~/Apply/AllegeNR.aspx?id="+Id+"");         }     }

    3.在新建的页面中写

      if (Request.QueryString["id"] != null)                 {                     int Id = int.Parse(Request.QueryString["id"]);

                        ServOneManager.ModifyImagePo(Id, strFullName);  //插入图片的方法                    }

    这样就可以把他的ID值给传过来


    最新回复(0)