15 April 2013

GridView (HyperLink) + DetailsView (QueryString)

You have a GridView. You add a HyperLink in the column to view the detailed information of the specific row in DetailsView. Here's a simple solution to make it work:


GridView:

<asp:HyperLinkField DataNavigateUrlFields="ContactId"
                    DataNavigateUrlFormatString="contactdetails.aspx?ID={0}" Text="Details" />


DetailsView:

<SelectParameters>
                <asp:QueryStringParameter DefaultValue="0" Name="ContactId"
                    QueryStringField="ID" />
            </SelectParameters>


Note: ContactId is the primary key of the table.

No comments:

Post a Comment