Solved

Need Help with Visual Web Developer Gridview Hyperlink problem

Posted on 2008-10-25
12
659 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
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

734 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