/aspxgridview-dataitemtemplate-hyperlink-popup

Show a popup when a user clicks a hyperlink in an ASPxGridView column's DataItemTemplate

Primary LanguageASP.NETOtherNOASSERTION

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.

Hyperlink Item Popup

Implementation Details

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);
}

Files to Look At

Documentation

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)