Solved

Need Help with Visual Web Developer Gridview Hyperlink problem

Posted on 2008-10-25
12
654 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
  • 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
 

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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction A frequently used term in Object-Oriented design is "SOLID" which is a mnemonic acronym that covers five principles of OO design.  These principles do not stand alone; there is interplay among them.  And they are not laws, merely princ…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now