温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

GridView弹窗更新

发布时间:2020-07-17 09:13:14 来源:网络 阅读:394 作者:gexu1990 栏目:编程语言

 aspx:

 

  1. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication4.WebForm1" %> 
  2.  
  3. <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> 
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  5. <html xmlns="http://www.w3.org/1999/xhtml"> 
  6. <head runat="server"> 
  7.     <title></title> 
  8. </head> 
  9. <body> 
  10.     <form id="form1" runat="server"> 
  11.     <asp:ScriptManager ID="ScriptManager1" runat="server" /> 
  12.     &nbsp; &nbsp; 
  13.     <div> 
  14.         &nbsp;<asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
  15.             <ContentTemplate> 
  16.                 <cc1:ModalPopupExtender TargetControlID="HiddenField1" BackgroundCssClass="modalBackground" 
  17.                     PopupControlID="Panel1" ID="ModalPopupExtender1" runat="server"> 
  18.                 </cc1:ModalPopupExtender>  
  19.                 <asp:HiddenField ID="HiddenField1" runat="server" /> 
  20.                  
  21.                 <asp:Panel ID="Panel1" runat="server" Height="50px" Width="125px" CssClass="confirmPanel" 
  22.                     Style="display: none"> 
  23.                     <asp:Button ID="Button2" runat="server" Text="确定" OnClick="Button2_Click" /> 
  24.                     <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
  25.                     <asp:Button ID="Button3" runat="server" Text="取消" /> 
  26.                 </asp:Panel> 
  27.                 <asp:GridView ID="GridView1" runat="server"> 
  28.                     <Columns> 
  29.                         <asp:TemplateField> 
  30.                             <ItemTemplate> 
  31.                                 <asp:Button ID="Button4" runat="server" Text="编辑" CommandArgument='<%# Eval("id") %>' 
  32.                                     OnClick="Button4_Click" /> 
  33.                             </ItemTemplate> 
  34.                         </asp:TemplateField> 
  35.                     </Columns> 
  36.                 </asp:GridView> 
  37.             </ContentTemplate> 
  38.         </asp:UpdatePanel> 
  39.     </div> 
  40.     </form> 
  41. </body> 
  42. </html> 

cs:

 

  1. using System; 
  2. using System.Collections.Generic; 
  3. using System.Linq; 
  4. using System.Web; 
  5. using System.Web.UI; 
  6. using System.Web.UI.WebControls; 
  7.  
  8. namespace WebApplication4 
  9.     public partial class WebForm1 : System.Web.UI.Page 
  10.     { 
  11.         protected void Page_Load(object sender, EventArgs e) 
  12.         { 
  13.  
  14.         } 
  15.  
  16.         protected void Button4_Click(object sender, EventArgs e) 
  17.         { 
  18.             int id = int.Parse((sender as Button).CommandArgument); 
  19.             TextBox1.Text = id.ToString(); 
  20.             ModalPopupExtender1.Show(); 
  21.         } 
  22.  
  23.         protected void Button2_Click(object sender, EventArgs e) 
  24.         { 
  25.             //更新数据 
  26.             //重新绑定gridview 
  27.             ModalPopupExtender1.Hide(); 
  28.         } 
  29.     } 

 

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI