Reputation: 7900
I have this GridView
in my page:
<asp:GridView ID="GridView2" runat="server" DataSourceID="SqlDataSource2"
AllowPaging="True" PageSize="20" CellPadding="4" ForeColor="#333333" GridLines="None">
<AlternatingRowStyle BackColor="White" />
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
And this is the SqlDataSource
:
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"
SelectCommand="SELECT country AS Country,count(country) As Count FROM client GROUP by country ORDER BY count(country) DESC;" ></asp:SqlDataSource>
And i want that the name will be hyper link to somethis like this:
/Details.aspx?country=countryname
How i can implement it?
Upvotes: 1
Views: 116
Reputation: 1
<asp:HyperLink runat="server" ID="HyperLink1" NavigateUrl='<%# "/Details.aspx?country=" + Eval("Country")%>' Text='Details'> </asp:HyperLink>
Upvotes: 0
Reputation: 34834
Use a <TemplateField>
with a HyperLink
control in it, like this:
<asp:GridView ...>
<Columns>
<asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:HyperLink runat="server" ID="HyperLink1"
NavigateUrl='<%# "Details.aspx?country=" + Eval("Country")%>'
Text='Details'>
</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Upvotes: 4