DataNavigateUrlFormatString with multiple fields

If you have an ASP.NET GridView with a HyperLinkfield you can not only pass just one DataField, but actually multiple in a very simple way.

The Property is already called DataNavigateUrlFields (with an s, hint, hint).

<asp:HyperLinkField DataNavigateUrlFields="iddocument,documentName" DataNavigateUrlFormatString="../DocumentDownload/{0}/{1}" DataTextField="documentName" HeaderText="Document" SortExpression="documentName" />

Not much more to it. Got the hint from AzamSharp. Alternatively you can always use a TemplateField, which gives you more flexibility.

<asp:TemplateField> <ItemTemplate> <asp:HyperLink ID="lnkShowFile1" runat="server" NavigateUrl='<%# "../DocumentDownload/" + Eval("iddocument") + "/" + Eval("documentName") %>' > <%# Eval("documentName") %> </asp:HyperLink> </ItemTemplate> </asp:TemplateField>

Ähnliche Beiträge

Leave a Reply

Your email address will not be published. Required fields are marked *