GridView控件中的两列如下:<asp:HyperLinkField DataNavigateUrlFields="NodeID"
DataNavigateUrlFormatString="BasicInfo.aspx?nodeID={0}"
Text="加载信息" HeaderText="加载" />
<asp:HyperLinkField DataNavigateUrlFields="NodeID" DataNavigateUrlFormatString="~/Display/NodeInfo.aspx?nodeID={0}
&previewPage=LastNodeInfo"
Text="查看信息" HeaderText="详细" />
小弟想请教:(1) nodeID={0} 这个{0}是什么意思?页面传值我只知道传递表单中控件的值或者viewstate之类;
(2)&的意思;
(3)指定previewPage有什么作用?
DataNavigateUrlFormatString="BasicInfo.aspx?nodeID={0}"
Text="加载信息" HeaderText="加载" />
<asp:HyperLinkField DataNavigateUrlFields="NodeID" DataNavigateUrlFormatString="~/Display/NodeInfo.aspx?nodeID={0}
&previewPage=LastNodeInfo"
Text="查看信息" HeaderText="详细" />
小弟想请教:(1) nodeID={0} 这个{0}是什么意思?页面传值我只知道传递表单中控件的值或者viewstate之类;
(2)&的意思;
(3)指定previewPage有什么作用?
DataSourceID="jianweinews" ShowHeader="False" Width="189px" GridLines="None" EmptyDataText="还没有数据" >
<Columns>
<asp:TemplateField ItemStyle-CssClass="hawk110" >
<ItemTemplate >
<asp:HyperLink ID=hyperlink runat="server" NavigateUrl=<%# "~/index/infopublishnews.aspx?newsID="+Eval("newsID")%>>传送</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<SelectedRowStyle BorderStyle="None" />
</asp:GridView>如果Eval("newsID")不会绑定的话就直接赋予给GridView 的一个数据源 数据源中包含newsID列。第二种 自己设置NavigateUrl
<asp:GridView ID="GridView3" runat="server" AutoGenerateColumns="False"
onrowdatabound="GridView3_RowDataBound" >
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server"><%#Eval("Name") %></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
后台
protected void GridView3_RowDataBound(object sender, GridViewRowEventArgs e)
{
string[] url = { "1.aspx", "2.aspx", "3.aspx" };
if (e.Row.RowType == DataControlRowType.DataRow)
{
HyperLink hl = e.Row.FindControl("HyperLink1") as HyperLink;
hl.NavigateUrl = url[e.Row.RowIndex];//这里超链接只是例子,具体设置为什么在自己修改
}
}