Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Refrence image in datagrid with OnItemDataBound

Reply
Thread Tools

Refrence image in datagrid with OnItemDataBound

 
 
David A. Coursey
Guest
Posts: n/a
 
      10-05-2004
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




 
Reply With Quote
 
 
 
 
Eric Cherng
Guest
Posts: n/a
 
      10-05-2004
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" <> 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.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
>
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ht get column in DataRowItem of datagrid at OnItemDataBound xzzy ASP .Net 3 06-18-2006 06:03 PM
Refrence image in template column David A. Coursey ASP .Net Datagrid Control 1 10-06-2004 11:04 AM
Group Policy refrence Rich MCSE 48 07-28-2004 09:39 PM
URGENT question about binding collection to a datagrid onitemdatabound ITnerd ASP .Net Datagrid Control 1 11-02-2003 11:55 AM
DataGrid OnItemDataBound problem in APS.NET C# Steven ASP .Net 1 07-09-2003 05:17 PM



Advertisments
 



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