We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Comb box or drop down boxes from losing their pervious values. after page load.

fjalbert
fjalbert asked
on
Medium Priority
240 Views
Last Modified: 2013-12-29
I am working with in a Gridview with a hyperlink control  ater i select and click the hyper link the page will reload and all my values in the comb boxs are gone.

Question how do I keep my comb box or drop down boxes from losing their pervious values.
After a page load event happens

Coding with vb.net

Thanks
Comment
Watch Question

Paul MacDonaldDirector, Information Systems
CERTIFIED EXPERT

Commented:
Are you re-binding the DDLs on postback?

What happens when a hyperlink is clicked (that is, does the visitor go to another page, are you running some routine, or are you posting back to the page with some parameter set?

Author

Commented:
I am posting back to the same page with a new parameter to open another record with in my form.
Paul MacDonaldDirector, Information Systems
CERTIFIED EXPERT

Commented:
...and every time the page loads, you're repopulating the DDLs?  Just guessing...

If so, you can either store the DDL values somewhere (maybe in session variables) or rework your code so you don't actually have to re-load the page.  It's the reloading that's causing everything to be "forgotten".

Author

Commented:
Yes I am re-binding the DDLs on postback on the Load event

Author

Commented:
I removed the DDLs on postback that will keep my comb box filed with the values but now the value go back to the first value within the comb box list.  
Full Stack .NET Developer
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
Paul MacDonaldDirector, Information Systems
CERTIFIED EXPERT

Commented:
@[yv989c]: I don't think that applies here since the OP is actually re-loading the page, not just posting back to it.

@[fjalbert]: Replace the hyperlink with a linkbutton control.  When the user clicks the linkbutton, have the OnCommand property call a sub in your codebehind that pushes the values of the DDLs/combobox into session variables, then do a Server.Redirect back to the page with the parameter you want to pass.  On Page.Load you can pull the values out of the session variables (after you've populated the DDLs/combobox) and set the values to what's stored in the session variables.

This is a very sloppy way of doing this, but not knowing more about what you're doing it's difficult to offer cleaner suggestions.
Carlos VillegasFull Stack .NET Developer

Commented:
Ohh I see, you are right paulmacd, I misunderstood the problem... then yes, he need to implement some kind of persistence, maybe a query string parameter to preserve those values.... he need to provide more info about the values to preserve.

Author

Commented:
Thanks
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.