Refrence image in template column

Ask a Question related to ASP.NET Data Grid Control, Design and Development.

  1. #1

    Default Refrence image in template column

    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.WebControl s.ListItemType.Item) ||
    e.Item.ItemType.Equals(System.Web.UI.WebControls.L istItemType.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 Guest

  2. Similar Questions and Discussions

    1. Need to change image of imagebutton in datagrid template column
      I'm going nuts.. I've got a template column with an imagebutton in it. I would like to change the image on the button when the button is clicked. ...
    2. Template column base on another column value
      Hello .net expert, I would like to change the color a a column "Name" base on the value of another column "tel" . Is it possible ??? Thanks in...
    3. Template Column
      If you handle DDL's SelectedIndexChanged event, you get the DDL instance itself from the first parameter of event handler method. Ok, in the control...
    4. Changing ImageURL of Image Button which is added in template column of datagrid
      hello, I have a template column in my datagrid. To the header of template colum, i have added imagebutton. On click of the imagebutton , i...
    5. Bound Column or Template Column (w dAdapater?) in DataGrid
      I am able to get the data using DataAdapter and the DataReader. I am more inclined to use DataAdapter because I want to update the data on the SQL...
  3. #2

    Default Re: Refrence image in template column

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

    "David A. Coursey" <dcoursey@gmail.com> wrote in message
    news:OaiJ7FlqEHA.376@TK2MSFTNGP14.phx.gbl...
    > 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.WebControl s.ListItemType.Item) ||
    >
    e.Item.ItemType.Equals(System.Web.UI.WebControls.L istItemType.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 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139