Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 13th, 2007, 04:52 AM
Registered User
 
Join Date: Apr 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default HTML link and gridview

Hi,

I am trying to create a link in a gridview. The data comes from one table and the link comes from another table.

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1"
            Style="z-index: 100; left: 95px; position: absolute; top: 203px" Width="295px">
            <Columns>
                <asp:BoundField DataField="Tipster" HeaderText="Tipster" SortExpression="Tipster" />
                <asp:BoundField DataField="Sport" HeaderText="Sport" SortExpression="Sport" />
                <asp:BoundField DataField="Pick" HeaderText="Pick" SortExpression="Pick" />
                <asp:BoundField DataField="Odds" HeaderText="Odds" SortExpression="Odds" />
                <asp:BoundField DataField="Wager" HeaderText="Wager" SortExpression="Wager" />
                <asp:BoundField DataField="Bookmaker" HeaderText="Bookmaker" SortExpression="Bookmaker" />
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString %>"
            ProviderName="<%$ ConnectionStrings:ASPNETDBConnectionString.Provide rName %>"
            SelectCommand="SELECT b.Tipster, b.Sport, b.Pick, b.Odds, b.Wager, '<a href='''+w.webbookie+''' target=''_blank''>'+w.Bookiename+'</a>' as Bookmaker FROM Bet as b, Website as w WHERE b.Bookmaker = w.BookieName">
        </asp:SqlDataSource>
    <a href="http://www.bbc.co.uk">William Hill</a>
    </div>
    </form>
</body>
</html>



However this does not work.

The link appears like this:



<a href='http://www.willhill.co.uk' target='_blank'>William Hill</a>

So the data is coming from the tables, but i just wanted to see William Hill and it to link to the website.



I have looked around to try to find a solution, but i am struggling.



Is there another way to do this in Asp.net's controls, or have i done something stupid in the code.



Many Thanks,



Oliver





 
Old May 13th, 2007, 06:15 PM
Authorized User
 
Join Date: Mar 2007
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In the gridview's breakout panel, set the HTMLEncode property to True. Look in the Behaviour section.

 
Old May 14th, 2007, 03:27 PM
Registered User
 
Join Date: Apr 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I had a look at the option and it was already on true, so turned it to false and hey presto it worked.

Thanks for that Startfarm, I thought the code looked ok, and I have spent days trying to make it work, never thought it would have been something like that.

Thanks again.

Oliver






Similar Threads
Thread Thread Starter Forum Replies Last Post
Link Play Window Media in GridView johnpie99 ASP.NET 2.0 Professional 0 April 12th, 2007 12:01 AM
How to add conditional link to GridView? asp_convert General .NET 1 February 9th, 2007 02:38 AM
Gridview Email Link ronhawker General .NET 0 November 9th, 2006 07:12 PM
Button link in gridview to open a www kherrerab ASP.NET 2.0 Basics 0 September 28th, 2006 01:53 PM
hyper link to gridview samir_katore .NET Framework 2.0 6 August 20th, 2006 10:38 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.