Rebind Image Control's ImageURL on postback

W

wardemon

Hi,
I have an image control which inside an ItemTemplate of a GridView
Control.
I've coded the ImageControl's ImageURL in "Source" to have a
dynamically filled-up value
ex: ImageURL = <%# FormatImageURL() %>
CodeBehind: private function FormatImageURL
{ DropdownlistControl.SelectedValue }

When page loads for the first time, everything is okay.
The ImageURL has the correct ImageURL , w/c is equivalent to the
DropDownListControls's default SelectedValue.

However, once I've manually change the DropDownList's selected value
in the UI,
after the page PostsBack, the ImageURL value remains the same, even
though
the DropDownListControl's SelectedValue has now been changed.

My question is now, how do I change the ImageControl's ImageURL value
whenever
I change the DropDownListControl's SelectedValue manually in the UI?

Thanks,
Henry Wu
 
G

Guest

Grid view picks up the dropdown value only when it binds to the data source.
So, you have to bind the it again (on post back) so that it can take the new
dropdown value.

Alternatively, on post back, you can loop-through the grid rows and change
each row's image URL based on the dropdown value.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top