当前位置:首页 > ASP.NET实例:在GridView使用HyperLinkField 属性的链接

ASP.NET实例:在GridView使用HyperLinkField 属性的链接

点击次数:960  更新日期:2010-12-27
\n

源程序如下:

<asp:GridView ID=”GridView1″ runat=”server” AllowPaging=”True” AllowSorting=”True” AutoGenerateColumns=”False” CellPadding=”4″ DataKeyNames=”LunWBH,LunWBT,ZhuangTMC” ForeColor=”#333333″ GridLines=”None” OnRowDeleting=”GridView1_RowDeleting” Width=”734px” OnSelectedIndexChanged=”GridView1_SelectedIndexChanged”>
<FooterStyle BackColor=”#507CD1″ Font-Bold=”True” ForeColor=”White” />
<Columns>
<asp:BoundField DataField=”LunWBH” HeaderText=”论文编号” InsertVisible=”False” ReadOnly=”True” />
<asp:BoundField DataField=”LunWBT” HeaderText=”论文标题” />
<asp:BoundField DataField=”ZhuangTMC” HeaderText=”状态名称” />
<asp:BoundField DataField=”TouGRQ” HeaderText=”投稿日期” />
<asp:CommandField HeaderText=”编辑” ShowDeleteButton=”True” />
<asp:HyperLinkField DataNavigateUrlFields=”LunWBT” DataNavigateUrlFormatString=”files/{0}.doc”
HeaderText=”查看” Target=”_blank” Text=”论文” />
<asp:HyperLinkField DataNavigateUrlFields=”LunWBH” DataNavigateUrlFormatString=”PingLXX.aspx?LunWBH={0}”
HeaderText=”查询” Text=”评论” />
</Columns>
<RowStyle BackColor=”#EFF3FB” Height=”2px” />
<EditRowStyle BackColor=”#2461BF” />
<SelectedRowStyle BackColor=”#D1DDF1″ Font-Bold=”True” ForeColor=”#333333″ />
<PagerStyle BackColor=”#2461BF” ForeColor=”White” HorizontalAlign=”Center” />
<HeaderStyle BackColor=”#507CD1″ Font-Bold=”True” ForeColor=”White” />
<AlternatingRowStyle BackColor=”White” />
</asp:GridView>

属性设置:
1.调用服务器上文件夹里面的文件
DataNavigateUrlFields=”LunWBT”
DataNavigateUrlFormatString=”files/{0}.doc”
files为服务器上放置文件的文件夹,{0}是以LunWBT为参数的参数
2.调用网页
DataNavigateUrlFields=”LunWBH”
DataNavigateUrlFormatString=”PingLXX.aspx?LunWBH={0}”
PingLXX.aspx调用网页,LunWBH要传得参数

来源:http://www.cnblogs.com/liulanglang/archive/2007/06/16/785411.html

\n