Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Controls (http://www.velocityreviews.com/forums/f63-asp-net-web-controls.html)
-   -   Refrence image in datagrid with OnItemDataBound (http://www.velocityreviews.com/forums/t774416-refrence-image-in-datagrid-with-onitemdatabound.html)

David A. Coursey 10-05-2004 07:32 PM

Refrence image in datagrid with OnItemDataBound
 
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





Eric Cherng 10-05-2004 11:30 PM

Re: Refrence image in datagrid with OnItemDataBound
 
You want to get a reference to your Image control. Something like...

Image img = (Image) e.Item.FindControl("imgWebStatus");
img.ImageUrl = ... your picture url here ...;

--
Eric Cherng
MCP, MCDBA, MCSD
http://echerng.com


"David A. Coursey" <dcoursey@gmail.com> wrote in message
news:%23LCnTIxqEHA.3896@TK2MSFTNGP15.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.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
>
>
>
>





All times are GMT. The time now is 05:25 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.