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
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