Refrence image in template column

Discussion in 'ASP .Net Datagrid Control' started by David A. Coursey, Oct 4, 2004.

  1. I am trying to change the image in my column depending on the status of the
    db field. All of the data is being populated correctly, I just haven't been
    able to get the image path to work.

    aspx page:

    <asp:boundcolumn visible="False" datafield="success" />
    <asp:templatecolumn headertext="Status" >
    <itemtemplate>
    <asp:image id="imgWebStatus" runat="server" imageurl="" />
    </itemtemplate>
    </asp:templatecolumn>



    aspx.cs codebehind page:


    if(e.Item.ItemType.Equals(System.Web.UI.WebControls.ListItemType.Item) ||
    e.Item.ItemType.Equals(System.Web.UI.WebControls.ListItemType.AlternatingItem))
    {
    switch(Convert.ToInt32(e.Item.Cells[0].Text))
    {
    case 0:
    {
    e.Item.Cells[1].WHAT_GOES_HERE = Request.ApplicationPath +
    "/images/no.gif";
    break;
    }



    Thanks for looking.

    David A. Coursey
     
    David A. Coursey, Oct 4, 2004
    #1
    1. Advertising

  2. Image i = (Image)e.Item.Cells[1].Controls[0];
    i.ImageUrl = yourPath;

    "David A. Coursey" <> wrote in message
    news:...
    > I am trying to change the image in my column depending on the status of

    the
    > db field. All of the data is being populated correctly, I just haven't

    been
    > able to get the image path to work.
    >
    > aspx page:
    >
    > <asp:boundcolumn visible="False" datafield="success" />
    > <asp:templatecolumn headertext="Status" >
    > <itemtemplate>
    > <asp:image id="imgWebStatus" runat="server" imageurl="" />
    > </itemtemplate>
    > </asp:templatecolumn>
    >
    >
    >
    > aspx.cs codebehind page:
    >
    >
    > if(e.Item.ItemType.Equals(System.Web.UI.WebControls.ListItemType.Item) ||
    >

    e.Item.ItemType.Equals(System.Web.UI.WebControls.ListItemType.AlternatingIte
    m))
    > {
    > switch(Convert.ToInt32(e.Item.Cells[0].Text))
    > {
    > case 0:
    > {
    > e.Item.Cells[1].WHAT_GOES_HERE = Request.ApplicationPath +
    > "/images/no.gif";
    > break;
    > }
    >
    >
    >
    > Thanks for looking.
    >
    > David A. Coursey
    >
    >
     
    Michael Tkachev, Oct 6, 2004
    #2
    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. Mike John
    Replies:
    1
    Views:
    509
    Axel Dahmen
    Jun 29, 2003
  2. Kevin Spencer
    Replies:
    0
    Views:
    483
    Kevin Spencer
    Jun 30, 2003
  3. Mike John

    How can I refrence the aspNetEmail

    Mike John, Jul 6, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    408
    dave wanta
    Jul 6, 2003
  4. Greg Phillips
    Replies:
    1
    Views:
    416
    Victor Bazarov
    May 26, 2004
  5. David A. Coursey

    Refrence image in datagrid with OnItemDataBound

    David A. Coursey, Oct 5, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    141
    Eric Cherng
    Oct 6, 2004
Loading...

Share This Page