image field in a grideview

  • Thread starter Thread starter ma
  • Start date Start date
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
 
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>
 
Back
Top