Click here to Skip to main content
16,004,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi there, please help me through, i have designed a form on my website,where a user is supposed to enter his webaddress, when i retrieve the data in the grid view control,i would love to have this webaddress as a hyperlink so that when i click on this link, am redirected to the website which the user entered as his webaddress.
Thanks in advance

Yours faithfully
Martin
Posted

Hi Martin,

Please do following:
XML
<asp:GridView ID="GridView1" runat="server" AllowPaging="true"  AutoGenerateColumns="false">
        <Columns>
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:HyperLink runat="server" ID="hylWebsite"
                        Text='<%#Eval("WebsiteName")%>' NavigateUrl='<%#Eval("WebsiteURL")%>'></asp:HyperLink>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>


Please do let me know, if you have any doubt.

Please provide Vote if this would be helpful to you.

Thanks,
Imdadhusen
 
Share this answer
 
v2
Comments
Hiren solanki 16-Sep-10 8:53am    
Here is your answer
m@dhu 16-Sep-10 9:13am    
Navigate url property used twice update it..
Sunasara Imdadhusen 16-Sep-10 9:29am    
Yes! i removed it :)
katumbamartin 17-Sep-10 8:20am    
Reason for my vote of 5
Automatic vote of 5 for accepting answer.
Do you mind pasting some code here so I can see.
Shouldn't be too hard just add the address to a linkbutton.
Regards
 
Share this answer
 
Comments
Simon_Whale 16-Sep-10 10:00am    
Please beaware comments goto the person who posted the answer.
Answers asking previous posters about their answers go the the OP (original poster)
Bardy85 16-Sep-10 10:04am    
Will do.
use item command or row command
take link button to display webaddress
assign commandname to linkbutton
check for commandname in itemcommand event
and then redirect using response .redirect

if you want exact code do let me knw
 
Share this answer
 
you can also use hyperlinkfield by default
<Columns>
        <asp:HyperLinkField Text="Websiteurl"  NavigateUrl='<%#Eval("WebsiteURL")%>'  Target="_blank"/>
        </Columns>
 
Share this answer
 
Comments
Dalek Dave 16-Sep-10 11:17am    
Good Call.

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