Popup with a gridview when a link is clicked - c#

Could someone help me out in getting a popup with a gridview(with 2 columns) inside when a link is clicked. 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. 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;
Drop a link in your markup that would open the grid; name it MyLink
Define the two column'ed GridView inside a Panel.
<asp:Panel runat="server" ID="pnlGrid"><asp:GridView ...></asp:Panel>
Drop ModalPopupExtender control from Ajax Control Toolkit in your markup.
Add Panel's id in ModalPopupExtender's markup
<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; dont forget to add GridView.EmptyDataText property, so that you'd know when there are no records to show.
Last, but not least, upon your page load, load the data from your database, and assign it your 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. With it you can create your panel control with the gridview and extend it with the modal popup extender. You will then hook up the link's click event to show the modal popup control (and any other databinding you need to do).
Thus when you click on the link, the panel will be displayed with the gridview.

If you are using Web Forms, an option would be to use the Ajax Control Toolkit's ModalPopup control. This control is very easy to add to a web forms page. 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.

Related

hyperlink control vs link button vs ImageButton vs button control in ASP.NET

What is difference between hyperlink control , link button , ImageButton , button control in ASP.NET. Which one to use when?
Let say I have requirement to show an image. On click of the image I need to do something. It can be done using above controls. Which one is better to use?
HyperLink is used to navigate, it renders to an anchor tag
LinkButton renders also to an anchor tag but with postback to server behavior. It's used to have a button with link look & feel.
ImageButton renders to an input control of type image and can be user to post to server or perform some client side action.
If you need to use that control to implement navigation, use HyperLink, otherwise you could use ImageButton

How to highlight the linkbutton when it's clicked.

Siva here.
I have used Default aspx page with bunch of link buttons in sidebar. Using asp panel i loaded the user control in panel. Here every thing is perfect. I can't highlight the active link button without post back.
ASP has a control called the Update panel (http://msdn.microsoft.com/en-us/library/bb386454(v=vs.100).aspx)
wich basicly allows you to call events while not using the postback trigger.
i hope this helps.

Load contents to an ajax tab when the user clicks on it

I have a page(C#-asp.net application) with more than 5 ajax tabs that gets data on page load. Since it takes a long time, i want to populate the tab contents only when the user clicks on the tab.not able to find any event in tab panel. BTW i'm using an AJAX Tab container Please Advice me ASAP.
Thanks in Advance. :)
You need to set AutoPostBack="true" add ActiveTabChanged to tab control. For details go here
Consider to extract tabs content to user controls and load them into active tab in Page_Load method depending on ActiveTabIndex property

Loading & Retrieving data from multiple user controls

I have multiple user controls on the page that are used primarily for data entry purposes. When a product is loaded, I need to load the product data into all those user controls and retrieve data when I need to save the product. The user controls are not visible to the user directly, instead user would click on a link and the user control will open up in a modal popup.
Currently the way I'm doing this is, I've loaded all the user controls on the page in separate div controls, and showing the modal popup when the link is clicked. I'm sure loading all the user controls on the page is not a good idea. Is there a better way to handle this? I think we can show the markup using JSON with jQuery - but how can I load and retrieve the data using that? Can someone help please?
Thanks.
Sounds like a case for AJAX. You could use an UpdatePanel within the div that defines the modal dialog. From the click handler for whatever control brings up a particular modal, you can dynamically replace one usercontrol with another in that UpdatePanel, pre-populate the usercontrol's data, then show a single modal that could be anything. Doesn't have to be a modal either; you could set up the UI with tab-like controls that switch between these UserControls in an always-visible div.
For a simpler approach, you could keep your Usercontrols in a div that is initially hidden by JQuery.
On postback, ie. when the user clicks the button/link for a particular product you can populate all your controls in a standard ASP.Net way so they're ready to display and then call a bit of JS/JQuery to show the div as a modal dialog.

How can i create a ModalPopupExtender control dynamically from a server control?

I have a composite server control that does quiet a number of things; one of which is to display a ModalPopup OnClick of a dynamically generated HtmlAnchor control.
I need to create this ModalPopupExtender control dynamically in my server control and trigger it from within.
I have been able to create it and trigger it from a button created at design time but not at runtime. This is as a result of the ID assign to the link is always not found by the ModalPopupExtender control.
I have tried assigning a static ID but no success. Can anyone help?
I figured it out. All i needed to do was recreate the HtmlAnchor control in the overridden CreateChildControls method on postback.
Thanks David for you concern.

Categories