Solved

Need Help with Visual Web Developer Gridview Hyperlink problem

Posted on 2008-10-25
12
658 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 

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

Industry Leaders: 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

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

762 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