Sunday, July 19, 2009

How to create dynamic links in a gridview

Whenever you are displaying results for a query you need to allow the user to click on a link that will bring them to an appropriate page. Put this in a GridView and customize to get the results you want:

<asp:TemplateField HeaderText="Subject">
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl='<%# Eval("ID", "~/Page.aspx?id={0}") %>'
Text='<%# Eval("Subject") %>'></asp:HyperLink>

No comments:

Post a Comment

There was an error in this gadget