从数据源asp.net gridview的DataNavigateUrlFormatString [英] asp.net gridview DataNavigateUrlFormatString from DataSource

查看:243
本文介绍了从数据源asp.net gridview的DataNavigateUrlFormatString的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个被填充从datasouce一个GridView。
即填充数据源的存储过程,有一个领域的客户端,并现场客户中的网站。

我想填充领域的客户在GridView列被称为客户端,这将是一个超链接字段和超链接字段是从数据集的客户网站的价值。客户端的网站是外部站点(不在我的ASP项目)

下面是我的html code。我怎样才能获得客户中的网站显示为DataNavigatrURL值?

 < ASP:HyperLinkField字段DataTextField =客户HEADERTEXT =客户DataNavigateUrlFields =客户端
                DataNavigateUrlFormatString =客户中的网站>
                < HeaderStyle Horizo​​ntalAlign =中心/>
                < ItemStyle Horizo​​ntalAlign =左/>
            < / ASP:HyperLinkField字段>
 

解决方案

使用数据绑定的NavigateUrl属性,像这样的:

  NavigateUrl ='<%#绑定(ClientWebSite)%>
 

或者更加充分:

 < ASP:HyperLinkField字段DataTextField ='<%#绑定(客户%>'HEADERTEXT =客户NavigateUrl ='<%#绑定(ClientWebSite )%>'>
    < HeaderStyle Horizo​​ntalAlign =中心/>
    < ItemStyle HorizantalAlign =左/>
< / ASP:HyperLinkField字段>
 

DataNavigateUrlFields 用来获取或设置从用于构造的URL在HyperLinkField字段对象中的超链接数据源字段的名称。

DataNavigateUrlFormatString`用来获取或设置指定了一个HyperLinkField字段对象的超级链接的URL的呈现格式字符串。

I have a gridview that is being populated from a datasouce.
The Stored procedure that is populating the datasource, has a field "Client" and a field "Client WebSite".

I want to populate the field "Client" in the gridview column called "Client" which would be a hyperlink field and the hyperlink field would be the "Client WebSite" value from the dataset. The client website is an external site (not within my asp project)

Below is my html code. How can I get the "Client WebSite" appear as the DataNavigatrURL value?

            <asp:HyperLinkField DataTextField="Client" HeaderText="Client" DataNavigateUrlFields="Client"
                DataNavigateUrlFormatString="Client WebSite">
                <HeaderStyle HorizontalAlign="Center" />
                <ItemStyle HorizontalAlign="Left" />
            </asp:HyperLinkField>

解决方案

Use databinding on the NavigateUrl attribute, like this:

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 is used to gets or set the names of the fields from the data source used to construct the URLs for the hyperlinks in the HyperLinkField object.

'DataNavigateUrlFormatString` is used to gets or sets the string that specifies the format in which the URLs for the hyperlinks in a HyperLinkField object are rendered.

这篇关于从数据源asp.net gridview的DataNavigateUrlFormatString的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆