Solved

Gridview boundfield question

Posted on 2016-09-12
4
48 Views
Last Modified: 2016-09-14
I have a gridview and I create the columns dynamically from a stored proc. I created an Imagefield (based on the name of the column "Status" being brought back from the sp) that will show an Image for different Statuses. My goal is to set a Session variable to the Status of the selected row. So when I click on a row in the grid Im trying to get the name of the image and then I can figure out the Status but I cannot seem to get the value of which image I have displayed in the row?
If I change it to a boundfield and check the Status column in the RowDataBound I can read it fine but if its an ImageField I cannot read the value.
The way I see it, I have 2 opitons.
I can keep the Imagefield and somehow try and figure out the image for the row and set a Session var to the rows Status. Or...I can change the imagefield to a boundfield and in the RowDataBound event somehow change the field to display an image based on the Status value in the column for the row?
I would much rather keep an ImageField and somehow be able to read the value of the ImageUrl and set my Session var based on that. But if I can find a way to create a Boundfield that holds the StatusID(1-5) and then set an image in the column value then thats fine too.
My problem is I dont know how to do either???
0
Comment
Question by:jknj72
  • 2
4 Comments
 
LVL 42

Expert Comment

by:zephyr_hex
ID: 41796238
Can you please show us the code where you're attempting to to get the ImageUrl value from the ImageField?
0
 
LVL 12

Accepted Solution

by:
Ramkisan Jagtap earned 500 total points
ID: 41796392
You can create two fields.
Boundfield to hold the statusid and  imagefield for the image.
From stored procedure you can add one more column with statusid to datasource and bind it to gridview.
On click of the row you can get the status id  and set it to session variable.
0
 

Author Comment

by:jknj72
ID: 41798387
thats a great idea and I will use it. I guess I was overthinking it...Thanks so much
0
 

Author Closing Comment

by:jknj72
ID: 41798390
thanks for your help
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now