Solved

Need Help with Visual Web Developer Gridview Hyperlink problem

Posted on 2008-10-25
12
660 Views
Last Modified: 2012-05-05
I am a beginner and I am using Visual Web Developer to create a website. In it, I have an Access DB in which I have a column of URLs for websites. I am using a GridView to show the data from the DB that comes from the AccessDataSource connecting to the DB. The GridView column is a hyperlink column and it lists the URLs as hyperlinks but when I click on them, it looks for them as is they are a page in the current project that I am creating( like http://www.mysite.com/www.cnn.com)   All of the websites are external websites, like www.cnn.com.

How do I set up the GridView to have the hyperlinks take me to the external sites?

Thanks for your help with this!!

0
Comment
Question by:mking777
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
12 Comments
 
LVL 13

Expert Comment

by:sm394
ID: 22804624
add link like that

<a href='<%# DataBinder.Eval(Container.DataItem, "link")%>' target="_blank">
                        <%# DataBinder.Eval(Container.DataItem, "title")%></a>
0
 

Author Comment

by:mking777
ID: 22804649
Where/how whould I put that in this section?
            <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False" DataSourceID="AccessDataSource1" Width="261px" PageSize="7">
                <Columns>
                    <asp:HyperLinkField DataTextField="URL" DataNavigateUrlFields="URL" HeaderText="BANKRUPTCY" />
                </Columns>
            </asp:GridView>
            <br />

Open in new window

0
 
LVL 13

Expert Comment

by:sm394
ID: 22804740
<Columns>
                <asp:TemplateField HeaderText="BANKRUPTCY">
                    <ItemTemplate>
                    <%#Container.DataItem %>
                   <a href='<%# DataBinder.Eval(Container.DataItem, "URL")%>' target="_blank">
                        <%# DataBinder.Eval(Container.DataItem, "URL")%></a>
                    </ItemTemplate>
                </asp:TemplateField>
             
            </Columns>
0
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 

Author Comment

by:mking777
ID: 22804811
Thanks but all it now shows is "System.Data.DataRowView " in the GridView. Any suggestions?
0
 
LVL 13

Expert Comment

by:sm394
ID: 22804921
Are Your urls starting with http://

or just www
0
 

Author Comment

by:mking777
ID: 22804929
Just www. Should I change it to also have http:// ?
0
 
LVL 13

Expert Comment

by:sm394
ID: 22804945
yes change to http://www.bbc.co.uk something like that
you can change in your table or you can try below i have embeded http:// in code
  <ItemTemplate>
                        <a href= <%# "http://"+ Eval( "ProductName")%> target="_blank">
                            <%# DataBinder.Eval(Container.DataItem, "ProductName")%></a>
                    </ItemTemplate>
0
 
LVL 13

Assisted Solution

by:sm394
sm394 earned 500 total points
ID: 22804952
if you change urls in your table from www to http://www 
then change this section <%# "http://"+ Eval( "ProductName")%>
to <%#  Eval( "URL")%>

 <ItemTemplate>
                        <a href= <%# Eval( "URL")%> target="_blank">
                            <%# DataBinder.Eval(Container.DataItem, "URL")%></a>
                    </ItemTemplate>
0
 

Accepted Solution

by:
mking777 earned 0 total points
ID: 22804960
Ok, I changed the data and it now does link the data to the correct site but still shows  "System.Data.DataRowView " in the GridView too. What do I do? Again, I appreciate your help.
0
 
LVL 13

Expert Comment

by:sm394
ID: 22804989
could you please post your code
0
 

Author Comment

by:mking777
ID: 22804999
Your solution worked. THANKS. I AWARDED YOU THE POINTS!!!
0
 
LVL 13

Expert Comment

by:sm394
ID: 22805029
Thanks but you should have accepted the solution by hiting Green Solution Accepted button  not by closing the question.
anyway glad your problem is resolved
Happy Coding :)
0

Featured Post

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question