Grid View for ASP.NET Web Forms - How to show a popup when a user clicks a hyperlink in a grid column's DataItemTemplate
This example shows how to create a grid that contains hyperlinks in one of its column's DataItemTemplate. When a user clicks a hyperlink, a popup dialog (ASPxPopupControl) is shown.
In this example, the Popup Control's ContentUrl property value is calculated in the ASPxHyperLink's Init event handler based on a data row's field value and the base URL value stored in the session.
The handler builds a JavaScript function that assigns the calculated ContentUrl value to the Popup Control on the client when a user clicks the link:
protected void hyperLink_Init(object sender, EventArgs e) {
ASPxHyperLink link = (ASPxHyperLink)sender;
GridViewDataItemTemplateContainer templateContainer = (GridViewDataItemTemplateContainer)link.NamingContainer;
int rowVisibleIndex = templateContainer.VisibleIndex;
string ean13 = templateContainer.Grid.GetRowValues(rowVisibleIndex, "EAN13").ToString();
string contentUrl = string.Format("{0}?EAN13={1}", Session["baseURL"], ean13);
link.NavigateUrl = "javascript:void(0);";
link.Text = string.Format("More Info: EAN13 - {0}", ean13);
link.ClientSideEvents.Click = string.Format("function(s, e) {{ OnMoreInfoClick('{0}'); }}", contentUrl);
}- Default.aspx (VB: Default.aspx)
- Default.aspx.cs (VB: Default.aspx.vb)
- Products.aspx (VB: Products.aspx)
- Products.aspx.cs (VB: Products.aspx.vb)
- Popup Control for ASP.NET Web Forms - How to show a pop-up window
- Popup Control for ASP.NET Web Forms - How to show and hide a pop-up window on the server side
- Grid View for ASP.NET MVC - How to display a hyperlink in a templated column
- Grid View for ASP.NET Web Forms - How to display a popup dialog when a user clicks a link in a grid row
(you will be redirected to DevExpress.com to submit your response)
