adding HTML formatting to a datagrid

Discussion in 'ASP .Net Datagrid Control' started by Ben, Jul 14, 2004.

  1. Ben

    Ben Guest

    Hello,

    I have a datagrid in an .aspx page that I'd like to add some HTML
    formatting to:

    <asp:BoundColumn DataField="Pict1" HeaderText="Picture" />
    <asp:BoundColumn DataField="PropertySite" HeaderText="Official
    Site" />

    The value returned from the datafield Pict1 is simply
    "/images/pict1.jpg"
    and the value returned by the datafield PropertySite is simply
    "http:/website.com"

    I'd like to add HTML formatting to every value in Pict1 that so that
    "images/pict1.jpg" becomes <img border="0" src="images/pict1.jpg"
    width="999" height="999"> and therefore shows a picture in the
    datagrid.

    I'd like to add similar formatting so that the value in PropertySite
    is an actual hyperlink.

    Can someone tell me how this might be possible? If I've posted to the
    wrong group I'd appreciate being directed to the correct one.
     
    Ben, Jul 14, 2004
    #1
    1. Advertising

  2. The direction: instead of BoundColumn use TemplateColumn. Put the <img> into
    the item template and databind src property to Pict1.

    Eliyahu

    "Ben" <> wrote in message
    news:...
    > Hello,
    >
    > I have a datagrid in an .aspx page that I'd like to add some HTML
    > formatting to:
    >
    > <asp:BoundColumn DataField="Pict1" HeaderText="Picture" />
    > <asp:BoundColumn DataField="PropertySite" HeaderText="Official
    > Site" />
    >
    > The value returned from the datafield Pict1 is simply
    > "/images/pict1.jpg"
    > and the value returned by the datafield PropertySite is simply
    > "http:/website.com"
    >
    > I'd like to add HTML formatting to every value in Pict1 that so that
    > "images/pict1.jpg" becomes <img border="0" src="images/pict1.jpg"
    > width="999" height="999"> and therefore shows a picture in the
    > datagrid.
    >
    > I'd like to add similar formatting so that the value in PropertySite
    > is an actual hyperlink.
    >
    > Can someone tell me how this might be possible? If I've posted to the
    > wrong group I'd appreciate being directed to the correct one.
     
    Eliyahu Goldin, Jul 15, 2004
    #2
    1. Advertising

  3. Ben

    Ben Guest

    "Eliyahu Goldin" wrote:

    > The direction: instead of BoundColumn use TemplateColumn. Put the <img> into
    > the item template and databind src property to Pict1.
    >
    > Eliyahu
    >
    > "Ben" <> wrote in message
    > news:...
    > > Hello,
    > >
    > > I have a datagrid in an .aspx page that I'd like to add some HTML
    > > formatting to:
    > >
    > > <asp:BoundColumn DataField="Pict1" HeaderText="Picture" />
    > > <asp:BoundColumn DataField="PropertySite" HeaderText="Official
    > > Site" />
    > >
    > > The value returned from the datafield Pict1 is simply
    > > "/images/pict1.jpg"
    > > and the value returned by the datafield PropertySite is simply
    > > "http:/website.com"
    > >
    > > I'd like to add HTML formatting to every value in Pict1 that so that
    > > "images/pict1.jpg" becomes <img border="0" src="images/pict1.jpg"
    > > width="999" height="999"> and therefore shows a picture in the
    > > datagrid.
    > >
    > > I'd like to add similar formatting so that the value in PropertySite
    > > is an actual hyperlink.
    > >
    > > Can someone tell me how this might be possible? If I've posted to the
    > > wrong group I'd appreciate being directed to the correct one.

    >
    >
    >
     
    Ben, Jul 16, 2004
    #3
  4. Ben

    Ben Guest

    I was able to use a "hyperlinkcolumn" to get the what I wanted as seen in the code below:

    <asp:HyperLinkColumn HeaderText="Property Site" DataTextField="PropertySite"></asp:HyperLinkColumn>

    But I could not get the image to work using Eliyahu instructions. Can someone send me the code syntax?
    Thanks, -Ben

    "Eliyahu Goldin" wrote:

    > The direction: instead of BoundColumn use TemplateColumn. Put the <img> into
    > the item template and databind src property to Pict1.
    >
    > Eliyahu
    >
    > "Ben" <> wrote in message
    > news:...
    > > Hello,
    > >
    > > I have a datagrid in an .aspx page that I'd like to add some HTML
    > > formatting to:
    > >
    > > <asp:BoundColumn DataField="Pict1" HeaderText="Picture" />
    > > <asp:BoundColumn DataField="PropertySite" HeaderText="Official
    > > Site" />
    > >
    > > The value returned from the datafield Pict1 is simply
    > > "/images/pict1.jpg"
    > > and the value returned by the datafield PropertySite is simply
    > > "http:/website.com"
    > >
    > > I'd like to add HTML formatting to every value in Pict1 that so that
    > > "images/pict1.jpg" becomes <img border="0" src="images/pict1.jpg"
    > > width="999" height="999"> and therefore shows a picture in the
    > > datagrid.
    > >
    > > I'd like to add similar formatting so that the value in PropertySite
    > > is an actual hyperlink.
    > >
    > > Can someone tell me how this might be possible? If I've posted to the
    > > wrong group I'd appreciate being directed to the correct one.

    >
    >
    >
     
    Ben, Jul 16, 2004
    #4
  5. Ben,

    Add a template column <asp:TemplateColumn ...> and in it use
    <ItemTemplate>
    <img border="0" src=<%# DataBinder.Eval (Container.DataItem, "Pict1") %>
    width="999" height="999">
    </ItemTemplate>

    Eliyahu

    "Ben" <> wrote in message
    news:...
    > I was able to use a "hyperlinkcolumn" to get the what I wanted as seen in

    the code below:
    >
    > <asp:HyperLinkColumn HeaderText="Property Site"

    DataTextField="PropertySite"></asp:HyperLinkColumn>
    >
    > But I could not get the image to work using Eliyahu instructions. Can

    someone send me the code syntax?
    > Thanks, -Ben
    >
    > "Eliyahu Goldin" wrote:
    >
    > > The direction: instead of BoundColumn use TemplateColumn. Put the <img>

    into
    > > the item template and databind src property to Pict1.
    > >
    > > Eliyahu
    > >
    > > "Ben" <> wrote in message
    > > news:...
    > > > Hello,
    > > >
    > > > I have a datagrid in an .aspx page that I'd like to add some HTML
    > > > formatting to:
    > > >
    > > > <asp:BoundColumn DataField="Pict1" HeaderText="Picture" />
    > > > <asp:BoundColumn DataField="PropertySite" HeaderText="Official
    > > > Site" />
    > > >
    > > > The value returned from the datafield Pict1 is simply
    > > > "/images/pict1.jpg"
    > > > and the value returned by the datafield PropertySite is simply
    > > > "http:/website.com"
    > > >
    > > > I'd like to add HTML formatting to every value in Pict1 that so that
    > > > "images/pict1.jpg" becomes <img border="0" src="images/pict1.jpg"
    > > > width="999" height="999"> and therefore shows a picture in the
    > > > datagrid.
    > > >
    > > > I'd like to add similar formatting so that the value in PropertySite
    > > > is an actual hyperlink.
    > > >
    > > > Can someone tell me how this might be possible? If I've posted to the
    > > > wrong group I'd appreciate being directed to the correct one.

    > >
    > >
    > >
     
    Eliyahu Goldin, Jul 18, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lars Netzel
    Replies:
    1
    Views:
    676
    =?Utf-8?B?QmluIFNvbmcsIE1DUA==?=
    May 14, 2004
  2. Dot net work
    Replies:
    2
    Views:
    672
    Rob C
    Dec 3, 2004
  3. =?Utf-8?B?c3Ryb3V0?=

    HTML formatting question in datagrid pager area.

    =?Utf-8?B?c3Ryb3V0?=, Jan 13, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    1,817
    Ken Cox [Microsoft MVP]
    Jan 14, 2005
  4. tvn
    Replies:
    5
    Views:
    694
    Stephen Sprunk
    Apr 5, 2010
  5. Replies:
    1
    Views:
    337
Loading...

Share This Page