且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ASP.Net:将客户端 onClick 添加到 GridView 中的超链接字段

更新时间:2023-10-04 16:07:52

我找到的解决方案是这样使用 asp:TemplateField ,同时不失去排序能力并使用 Eval 使用数据文本字段:

The solution I found was using asp:TemplateField this way, without losing the Sorting ability and using the datatextfield using Eval:

 <asp:TemplateField HeaderText="Name" SortExpression="PartnerName">
<ItemTemplate>
        <a onclick="javascript:alert('ok')" href="http://<%#Eval("PartnerName")%>"><%#Eval("PartnerName")%></a>
</ItemTemplate></asp:TemplateField>