首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

GridView 超链接传值有关问题

2013-07-01 
GridView 超链接传值问题求高手帮忙看下,关于GridView 超链接传值问题。asp:GridView IDGridView1 runa

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>
&nbsp;<asp:LinkButton ID="lbnFirst" runat="Server" CommandArgument="First" CommandName="Page" 
                                    Enabled="<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>" Text="首页"></asp:LinkButton>
                                &nbsp;<asp:LinkButton ID="lbnPrev" runat="server" CommandArgument="Prev" 
                                    CommandName="Page" 
                                    Enabled="<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>" 
                                    Text="上一页"></asp:LinkButton>
                                &nbsp;<asp:LinkButton ID="lbnNext" runat="Server" CommandArgument="Next" 
                                    CommandName="Page" 
                                    Enabled="<%# ((GridView)Container.NamingContainer).PageIndex != (((GridView)Container.NamingContainer).PageCount - 1) %>" 
                                    Text="下一页"></asp:LinkButton>
                                &nbsp;<asp:LinkButton ID="lbnLast" runat="Server" CommandArgument="Last" 
                                    CommandName="Page" 
                                    Enabled="<%# ((GridView)Container.NamingContainer).PageIndex != (((GridView)Container.NamingContainer).PageCount - 1) %>" 


                                    Text="尾页"></asp:LinkButton>
                                &nbsp;到第<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>

热点排行