Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 93
  • Last Modified:

Gridview boundfield question

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
jknj72
Asked:
jknj72
  • 2
1 Solution
 
zephyr_hex (Megan)DeveloperCommented:
Can you please show us the code where you're attempting to to get the ImageUrl value from the ImageField?
0
 
Ramkisan JagtapLead DeveloperCommented:
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
 
jknj72Author Commented:
thats a great idea and I will use it. I guess I was overthinking it...Thanks so much
0
 
jknj72Author Commented:
thanks for your help
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now