本文介绍了如何在新的弹出窗口中查看和编辑网格视图值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! < asp:TemplateField > < ItemTemplate > < asp:LinkButton ID = HyperLink1 runat = server 文字 = 查看 CommandName = Vview / > < / ItemTemplate > < / asp:TemplateField > < asp:TemplateField > < ItemTemplate > < asp:LinkButton ID = HyperLink2 runat = server 文字 = 编辑 CommandName = Vedit / > < / ItemTemplate > ; < / asp:TemplateField > < asp:TemplateField > < ItemTemplate > < asp:LinkButton ID = HyperLink3 runat = server 文本 = 删除 CommandArgument =' <% #Eval( MsID) %> ' CommandName = Vdelete OnClientClick = 返回ConfirmOnDelete(''); / > < / ItemTemplate > < / asp:TemplateField > 受保护 void Grdmilestones_RowCommand( object sender,GridViewCommandEventArgs e) { GridViewRow gvr =(GridViewRow )((对照)e.CommandSource).NamingContainer; if (e.CommandName == Vview) { Label lb =(Label)gvr.FindControl( Label1\" 的); sqlstr = 从里程碑中选择MsID,标题,描述,日期,脚本; FillGrid(); } if (e.CommandName == Vedit) { Label lb =(Label)gvr.FindControl( Label2\" 的); sqlstr = 从里程碑中选择MsID,标题,描述,日期,脚本; FillGrid(); } if (e.CommandName == Vdelete) { int ID = Convert.ToInt32(e.CommandArgument.ToString()) ; sqlstr = 删除里程碑,其中MsID = + ID; con.Open(); SqlCommand cmd = new SqlCommand(sqlstr,con); cmd.ExecuteNonQuery(); con.Close(); FillGrid(); } FillGrid(); } 解决方案 添加新的aspx页面以接受要显示的值。单击Gridview的View Link,在Modal中显示此页面,并使用查询字符串或其他东西将Grid行值传递给此新页面。 打开模态(另一页如Popup )在Jquery中很容易。 < script language = javascript > (文件).ready(function(){ tb_show(HAI,yourPage.aspx?KeepThis = true& TB_iframe = true& width = 300& height = 200,null); } ); < / script > 见下文。它可能对你有帮助。 http://www.c-sharpcorner.com/UploadFile/9f0ae2/gridview-edit-delete-and-update-in-Asp-Net/ 您可以使用ASP.NET AJAX控件工具包中的 ModalPopupExtender 控件来完成此操作。 我有一篇文章(和源代码)我正在使用 ModalPopupExtender 。以下是链接:高级ASPX GridView分页和数据实体 [ ^ <asp:TemplateField> <ItemTemplate> <asp:LinkButton ID="HyperLink1" runat="server" Text="View" CommandName="Vview" /> </ItemTemplate> </asp:TemplateField> <asp:TemplateField> <ItemTemplate> <asp:LinkButton ID="HyperLink2" runat="server" Text="Edit" CommandName="Vedit" /> </ItemTemplate> </asp:TemplateField> <asp:TemplateField> <ItemTemplate> <asp:LinkButton ID="HyperLink3" runat="server" Text="Delete" CommandArgument='<%# Eval("MsID") %>' CommandName="Vdelete" OnClientClick="return ConfirmOnDelete('');" /> </ItemTemplate> </asp:TemplateField>protected void Grdmilestones_RowCommand(object sender, GridViewCommandEventArgs e) { GridViewRow gvr = (GridViewRow)((Control)e.CommandSource).NamingContainer; if (e.CommandName == "Vview") { Label lb = (Label)gvr.FindControl("Label1"); sqlstr = "select MsID,Title,Description,Date,Script from Milestones"; FillGrid(); } if (e.CommandName == "Vedit") { Label lb = (Label)gvr.FindControl("Label2"); sqlstr = "select MsID,Title,Description,Date,Script from Milestones"; FillGrid(); } if (e.CommandName == "Vdelete") { int ID = Convert.ToInt32(e.CommandArgument.ToString()); sqlstr = "Delete Milestones where MsID=" + ID; con.Open(); SqlCommand cmd = new SqlCommand(sqlstr, con); cmd.ExecuteNonQuery(); con.Close(); FillGrid(); } FillGrid(); } 解决方案 Add a new aspx Page to accept the values to to display. Show this Page in Modal on click of View Link of gridview and pass Grid row value to this new Page using query string or something.Opening Modal(another Page like Popup) is very easy in Jquery.<script language="javascript">(document).ready(function() { tb_show("HAI","yourPage.aspx?KeepThis=true&TB_iframe=true&width=300&height=200",null); });</script>See below article. It might help you.http://www.c-sharpcorner.com/UploadFile/9f0ae2/gridview-edit-delete-and-update-in-Asp-Net/You can do this by using ModalPopupExtender control from the ASP.NET AJAX Control Toolkit .I have an article (and source code) where I am using ModalPopupExtender. Here is the link: Advanced ASPX GridView Pagination and Data Entities[^] 这篇关于如何在新的弹出窗口中查看和编辑网格视图值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-24 09:37