日期:2014-05-17  浏览次数:20392 次

asp.net中GridView中的某列实现超链接
我的源码:
 <asp:GridView ID="Lj" runat="server" AutoGenerateColumns="False" 
            Width="90%" OnRowDeleting="Lj_RowDeleting" 
            OnRowDataBound="Lj_RowDataBound"  AllowPaging="True" >
            <Columns>
                <asp:BoundField HeaderText="网站名称" DataField="lname" />
                <asp:BoundField DataField="ldz" HeaderText="网站地址"  />
                 <asp:CommandField HeaderText="删除" ShowDeleteButton="True">
                                <ControlStyle Font-Underline="False" ForeColor="Black" />
                            </asp:CommandField>               
            </Columns>
        </asp:GridView>

我想实现的是在网站地址那一列实现超链接,点击某个地址后,自动跳转到相应网站,我应该怎样修改来实现?
跪求答案啊!!!!   

------解决方案--------------------
引用:
引用:<asp:TemplateField HeaderText="网站地址" SortExpression="ldz">
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                    <……

这样呢
 <asp:TemplateField HeaderText="网站地址" SortExpression="ldz">
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                    <ItemTemplate>
                    <asp:HyperLink ID="hpCardcode" runat="server" NavigateUrl='<%#Eval("ldz") %>'><%# Eval("ldz")%></asp:HyperLink>
                    </ItemTemplate>
                </asp:TemplateField>