image field in a grideview

M

ma

Hello,

I have a grideview which is bound to a database. I want that based on the
value of one field on the database one image is shown in the gideview. For
example assume that I have a field in database called status_code. I want to
display an OK image when it is 0 and an alarm image when it is 1.



I tried to do this by creating two cells in the gride view. One of them is
bound to database field and the other one is a template field with an image
control in it. (Cell no 4 is the status_code and cell 5 is the image. Cell 4
is invisible to user)



I tried to catch RowCreated event and then set the image control in cell 5
to the correct image. But I am not successful.



Here is a code snippets:



if (e.Row.RowIndex != -1)

{

switch (int.Parse(e.Row.Cells[4].Text))

{

case 0:

// set the image control.

break;

}

}

This code doesn't work as it complains that
(int.Parse(e.Row.Cells[4].Text)) is not correct ( text value is not in
correct format)

My questions:

1- Is there any better way to do this?

2- How can I read the value of cell[4]?

3- How can I set the image control to show the correct image?



Regards

Regards
 
M

Michael Nemtsev, MVP

Hello ma,

I suppose you need to start from there http://www.syncfusion.com/FAQ/aspnet/WEB_c4c.aspx#q109q

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


m> I have a grideview which is bound to a database. I want that based on
m> the value of one field on the database one image is shown in the
m> gideview. For example assume that I have a field in database called
m> status_code. I want to display an OK image when it is 0 and an alarm
m> image when it is 1.
m>
m> I tried to do this by creating two cells in the gride view. One of
m> them is bound to database field and the other one is a template field
m> with an image control in it. (Cell no 4 is the status_code and cell 5
m> is the image. Cell 4 is invisible to user)
m>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top