简体   繁体   English

单击链接时弹出带有gridview的窗口

[英]Popup with a gridview when a link is clicked

Could someone help me out in getting a popup with a gridview(with 2 columns) inside when a link is clicked. 当单击链接时,有人可以帮我得到一个带有gridview(带有2列)的弹出窗口吗? I need some help badly. 我急需一些帮助。 Can someone please tel me how to start and the procedure. 有人可以给我打电话的方式和程序。 I will be thankful. 我会很感激的。 2 columns in the gridview include checkbox and Text. gridview中的2列包括复选框和Text。 This should get populated from database and after modifying that. 这应该从数据库中填充,然后进行修改。 it should save it in the database!! 它应该将其保存在数据库中!

I really appreciate all your help!! 我真的很感谢你的帮助! Thanks! 谢谢!

If you have no time, and you want things to work "magically"; 如果您没有时间,并且希望事情“神奇地”工作; go download Ajax Control Toolkit ; 去下载Ajax Control Toolkit ;

  1. Drop a link in your markup that would open the grid; 在您的标记中放置一个可以打开网格的链接; name it MyLink 命名为MyLink
  2. Define the two column'ed GridView inside a Panel . Panel定义两列的GridView。

<asp:Panel runat="server" ID="pnlGrid"><asp:GridView ...></asp:Panel>

  1. Drop ModalPopupExtender control from Ajax Control Toolkit in your markup. 从Ajax Control Toolkit中删除ModalPopupExtender控件到您的标记中。
  2. Add Panel's id in ModalPopupExtender 's markup ModalPopupExtender的标记中添加面板的ID

<act:ModalPopupExtender ID="MyModalPopupExtender1" runat="server" TargetControlID="MyLink" PopupControlID="pnlGrid" style="display:none" OkControlID="MyOkButton"/>

Now clicking on the MyLink would open the Popup with GridView inside; 现在单击MyLink将打开内部带有GridView的Popup; dont forget to add GridView.EmptyDataText property, so that you'd know when there are no records to show. 不要忘记添加GridView.EmptyDataText属性,这样您就知道什么时候没有记录可以显示。

Last, but not least, upon your page load, load the data from your database, and assign it your GridView.DataSource 最后但并非最不重要的一点是,在页面加载后,从数据库加载数据,然后将其分配给GridView.DataSource

This article is a good start. 本文是一个好的开始。 Enjoy! 请享用!

Assuming you are using asp.net webforms, the easiest way to do this is to use the Microsoft Ajax Toolkit . 假设您正在使用asp.net Webforms,最简单的方法是使用Microsoft Ajax Toolkit With it you can create your panel control with the gridview and extend it with the modal popup extender. 使用它,您可以使用gridview创建面板控件,并使用模式弹出扩展器对其进行扩展。 You will then hook up the link's click event to show the modal popup control (and any other databinding you need to do). 然后,您将链接该链接的click事件以显示模式弹出控件(以及您需要执行的任何其他数据绑定)。

Thus when you click on the link, the panel will be displayed with the gridview. 因此,当您单击链接时,面板将显示为gridview。

If you are using Web Forms, an option would be to use the Ajax Control Toolkit's ModalPopup control. 如果使用的是Web窗体,则可以选择使用Ajax控件工具包的ModalPopup控件。 This control is very easy to add to a web forms page. 此控件很容易添加到Web表单页面。 It will allow you to extend the link with the modal and load the gridview in a panel that the modal popup will then display. 它将允许您使用模式扩展链接,并将gridview加载到随后将显示模式弹出窗口的面板中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM