Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more: , +
Hi All,

I want to dynamically bind a values from database into a gridview hyperlink.

pls help me!!
Posted

Hi,
Create templatefield within grid view. Add hyperlink and use Eval or Bind to asign value to desired hyperlink property.
 
Share this answer
 
In your gridview design add a template field with a hyperlink

C#
<asp:templatefield headertext="Download" xmlns:asp="#unknown">
<itemtemplate> 
 <asp:hyperlink id="hlDownload" runat="server">
   NavigateUrl='<%# "~/Downloads"+Eval("FileName") %>' 
   Text="Download" Target='<%# "_blank" %>'></asp:hyperlink>
</itemtemplate>                                       
</asp:templatefield>



Then you can bind the data with a field name 'FileName' to the gridview
 
Share this answer
 
Comments
Greesemonkey3 16-Apr-13 12:30pm    
Solution 3 works perfectly!!! Thank you so much, I have been trying to figure this out for a while!
babamoni 3-Aug-14 7:02am    
thank you
Tomas Takac 19-Dec-14 4:00am    
If the solution is usefull, accept it. This way you give credit to the people who help you. Please note you can accept multiple solutions if they are answering your question.
Tomas Takac 19-Dec-14 4:01am    
OK, I just noticed the dates. Very weird. The post was at the top of the list in Q&A. My applogies.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900