Click here to Skip to main content
Sign Up to vote bad
good
See more: ASP.NET
I want to add coulmn to gridview in ASP.NET this coulmn contain Hyperlink and i want to navigate to this hyperlink.
 
How can i do this in asp.net(C#)?
Posted 7 Jan '11 - 0:29
eman88572
Edited 7 Jan '11 - 0:47


3 solutions

There are two ways. You can create HyperLinkField or add a Hyperlink in <asp:templatefield >
 
Ex.
<Columns>
                <asp:HyperLinkField DataTextField="LeadID" DataNavigateUrlFields="LeadID" DataNavigateUrlFormatString="LeadInformation.aspx?LeadID={0}" Text="Lead ID" />
                <asp:BoundField DataField="DateTime" HeaderText="Date Updated" />
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Bind("LeadID") + Request.QueryString("type") %>'
                            Text=""></asp:HyperLink>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
>
 

  Permalink  
Comments
Kasson - 7 Jan '11 - 7:01
5 from me too. Good Call.
eman88 - 7 Jan '11 - 6:52
thank u for answer ,,,,, but maybe i don't explain what i exactlly want to do ... i retrive data in datatable from data base (product_name,Product_price,Product_link) i want to display that in gridview every product and its information and link to the page of each product thanks
Espen Harlinn - 7 Jan '11 - 6:45
5+ Nice and to the point :)
Sandeep Mewara - 7 Jan '11 - 6:48
Good Answer SMP! 5+
nagendrathecoder - 7 Jan '11 - 6:48
Nice answer, 5+ from me too. :)
Member 4343516 - 30 Oct '12 - 10:44
sdasdasd asdasd
You can add a TemplateField in the GridView control using the Edit Column
option from the context menu when you click on the smart tag.
 
1. Add a TemplateField in the Selected Fields list.
 
2. Now Right click on the Grid and select Edit Templates. Now drop the
Hyperlink control in the ItemTemplate of the Grid.
 
3. Now bind the NavigateURL and Text property of the Hyperlink to the
hyperlink column field in the table using Data Bindings.
 
4. Now if you click on the hyperlink, it will take you to that page.
  Permalink  
Comments
eman88 - 7 Jan '11 - 8:28
thank u sooo much
how to add hyperlink to grid view
 
i have recorded this vedeo hope it will be help
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 445
1 OriginalGriff 295
2 Arun Vasu 253
3 Zoltán Zörgő 194
4 CPallini 173
0 Sergey Alexandrovich Kryukov 10,105
1 OriginalGriff 7,739
2 CPallini 4,181
3 Rohan Leuva 3,482
4 Maciej Los 2,999


Advertise | Privacy | Mobile
Web01 | 2.6.130523.1 | Last Updated 30 Jul 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid