Asp.net gridview DataNavigateUrlFormatString from DataSource

I have a gridview that populates from datasouce.
The stored procedure that populates the data source has a Client field and a Client website field.

I want to fill in the “Client” field in the gridview column called “Client”, which will be the hyperlink field, and the hyperlink field will be the “Client Website” value from the dataset. The client website is an external site (not in my asp project)

Below is my html code. How can I make the "Client Website" display as the value of DataNavigatrURL?

<asp:HyperLinkField DataTextField="Client" HeaderText="Client" DataNavigateUrlFields="Client" DataNavigateUrlFormatString="Client WebSite"> <HeaderStyle HorizontalAlign="Center" /> <ItemStyle HorizontalAlign="Left" /> </asp:HyperLinkField> 
+3
source share
1 answer

Use data binding in the NavigateUrl attribute, for example:

 NavigateUrl = '<%# Bind("ClientWebSite") %>' 

Or more fully:

 <asp:HyperLinkField DataTextField='<%# Bind("Client" %>' HeaderText="Client" NavigateUrl='<%# Bind("ClientWebSite") %>'> <HeaderStyle HorizontalAlign="Center" /> <ItemStyle HorizantalAlign="Left" /> </asp:HyperLinkField> 

DataNavigateUrlFields used to get or set field names from the data source used to create URLs for hyperlinks in a HyperLinkField object.

'DataNavigateUrlFormatString` is used to get or set a string that defines the format in which URLs for hyperlinks are displayed in a HyperLinkField object.

+2
source

Source: https://habr.com/ru/post/916656/


All Articles