如何在 C#.Net 中将一列 sql 作为超链接

本文关键字:一列 sql 超链接 Net | 更新日期: 2023-09-27 18:36:18

想要在列上显示为超链接(例如:显示文本应单击此处,单击超链接时应打开一个URL。 你能帮帮我吗

如何在 C#.Net 中将一列 sql 作为超链接

我想

你想用 asp.net 来做。

<Columns>
<!-- first column-->
    <asp:BoundField DataField="Name" HeaderText="Name" ItemStyle-Width="150" /> 
<!-- second column-->
    <asp:BoundField DataField="Country" HeaderText="Country" ItemStyle-Width="150" />       
<!-- third column-->
    <asp:BoundField DataField="Town" HeaderText="Country" ItemStyle-Width="150" /> 
<!-- fourth column as hyperlink -->
    <asp:TemplateField>
        <ItemTemplate>
            <asp:HyperLink runat="server" NavigateUrl='<%# string.Format("~/Details.aspx?Id={0}&Name={1}&Country={2}",
                HttpUtility.UrlEncode(Eval("Id").ToString()), HttpUtility.UrlEncode(Eval("Name").ToString()), HttpUtility.UrlEncode(Eval("Country").ToString())) %>'
                Text="View Details" />
        </ItemTemplate>
    </asp:TemplateField>
</Columns> 

您可以查看此链接