Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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 1:29am
eman88595
Edited 7-Jan-11 1:47am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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 at 7-Jan-11 8:28am
   
thank u sooo much
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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  
v2
Comments
Kasson at 7-Jan-11 7:01am
   
5 from me too. Good Call.
eman88 at 7-Jan-11 6:52am
   
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 at 7-Jan-11 6:45am
   
5+ Nice and to the point :)
Sandeep Mewara at 7-Jan-11 6:48am
   
Good Answer SMP! 5+
nagendrathecoder at 7-Jan-11 6:48am
   
Nice answer, 5+ from me too. :)
Member 4343516 at 30-Oct-12 10:44am
   
sdasdasd
asdasd
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

//--For Dynamic and databind GridViews, it is better to create dynamic hyperlinks as
 
for (int i = 0; i < GridView1.Rows.Count; i++)
{
HyperLink hlContro = new HyperLink();
hlContro.NavigateUrl = "./newPage.aspx?ID=" + GridView1.Rows[i].Cells[0].Text;
hlContro.ImageUrl = "./sample.jpg";
hlContro.Text = "Documents";
GridView1.Rows[i].Cells[0].Controls.Add(hlContro);
}
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

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
0 OriginalGriff 329
1 Maciej Los 290
2 Sergey Alexandrovich Kryukov 230
3 Shweta N Mishra 185
4 PIEBALDconsult 149
0 OriginalGriff 7,660
1 Sergey Alexandrovich Kryukov 7,072
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,760


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 28 Feb 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100