Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / September 2007

Tip: Looking for answers? Try searching our database.

image field in a grideview

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ma - 21 Sep 2007 11:05 GMT
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
Michael Nemtsev, MVP - 21 Sep 2007 13:22 GMT
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>

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.