GridView 超链接传值问题
求高手帮忙看下,关于GridView 超链接传值问题。<asp:GridView ID="GridView1" runat="server" Height="375px" Width="894px" AutoGenerateColumns="False"
EnableModelValidation="True" AllowPaging="True" BorderColor="White" PageSize="20"
ShowHeader="False">
<AlternatingRowStyle BorderColor="White" />
<Columns>
<asp:BoundField DataField="id" HeaderText="id" Visible="False" />
<asp:HyperLinkField DataNavigateUrlFormatString="Articals.aspx?id={0}" DataTextField="Name"
HeaderText="标题" DataNavigateUrlFields="name">
<ItemStyle Width="80%" HorizontalAlign="Left" />
</asp:HyperLinkField>
<asp:BoundField DataField="AddDate" HeaderText="时间">
<ItemStyle Width="20%" />
</asp:BoundField>
</Columns>
<EditRowStyle BorderColor="White" />
<PagerTemplate>
<pagertemplate>
<br />
<asp:Label ID="lblPage" runat="server"
Text='<%# "第" + (((GridView)Container.NamingContainer).PageIndex + 1) + "页/共" + (((GridView)Container.NamingContainer).PageCount) + "页" %> '></asp:Label>
<asp:LinkButton ID="lbnFirst" runat="Server" CommandArgument="First" CommandName="Page"
Enabled="<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>" Text="首页"></asp:LinkButton>
<asp:LinkButton ID="lbnPrev" runat="server" CommandArgument="Prev"
CommandName="Page"
Enabled="<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>"
Text="上一页"></asp:LinkButton>
<asp:LinkButton ID="lbnNext" runat="Server" CommandArgument="Next"
CommandName="Page"
Enabled="<%# ((GridView)Container.NamingContainer).PageIndex != (((GridView)Container.NamingContainer).PageCount - 1) %>"
Text="下一页"></asp:LinkButton>
<asp:LinkButton ID="lbnLast" runat="Server" CommandArgument="Last"
CommandName="Page"
Enabled="<%# ((GridView)Container.NamingContainer).PageIndex != (((GridView)Container.NamingContainer).PageCount - 1) %>"
Text="尾页"></asp:LinkButton>
到第<asp:TextBox ID="inPageNum" runat="server"></asp:TextBox>
页
<asp:Button ID="BtnGo" runat="server" Text="Go" />
<br />
</pagertemplate>
</PagerTemplate>
</asp:GridView>
想要实现点击name列的内容时传递前面隐藏的id列的值,望高手指点下!
[解决办法]
Articals.aspx?id=<%# Eval("id") %>
[解决办法]
试试这样
<asp:HyperLinkField DataNavigateUrlFormatString="Articals.aspx?id={0}" DataTextField="Name"
HeaderText="标题" DataNavigateUrlFields="id">
<ItemStyle Width="80%" HorizontalAlign="Left" />
</asp:HyperLinkField>