在asp.net中将boundfield转换为超链接?

时间:2013-04-19 08:28:04

标签: hyperlink

我想问一下如何将其转换为超链接?

 <asp:BoundField DataField="ProductName" HeaderText="Product Name" ReadOnly="True" />

2 个答案:

答案 0 :(得分:1)

HyperLinkField应该没问题。它看起来像:

<asp:HyperLinkField DataNavigateUrlFields="MyUrl"
                    DataTextField="ProductName"
                    HeaderText="Product Name"
                    Target="_blank"
/>

其中 MyUrl 是包含超链接的DataSource中的公共属性名称。使用 DataNavigateUrlFormatString 属性格式化URL可能很有用,例如:

DataNavigateUrlFormatString="/display/something/form.aspx?ID={0}"

如果你想构建更复杂的锚 href 属性。

答案 1 :(得分:0)

示例完成:

<asp:HyperLinkField DataNavigateUrlFields="COD_DISC" datanavigateurlformatstring="~\otherview.aspx?COD_DISC={0}"  DataTextField="NOM_DISC" HeaderText="Name Column" Target="_self"/>

然后你在'otherview'中获得查询字符串的值。例如:

            if (Request.QueryString["COD_DISC"] != null)
            urlParamentro = Request.QueryString["COD_DISC"].ToString();
相关问题