Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2011-04-22
9
Medium Priority
?
216 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
0
Comment
Question by:fjalbert
  • 4
  • 3
  • 2
9 Comments
 
LVL 35

Expert Comment

by:Paul MacDonald
ID: 35448559
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?
0
 

Author Comment

by:fjalbert
ID: 35448675
I am posting back to the same page with a new parameter to open another record with in my form.
0
 
LVL 35

Expert Comment

by:Paul MacDonald
ID: 35448721
...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".
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:fjalbert
ID: 35448928
Yes I am re-binding the DDLs on postback on the Load event

0
 

Author Comment

by:fjalbert
ID: 35448962
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.  
0
 
LVL 17

Accepted Solution

by:
Carlos Villegas earned 2000 total points
ID: 35449024
Hello, you are doing this right?
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
	If Not Me.IsPostBack Then
	    'Fill my combos here!
	End If
End Sub

Open in new window

0
 
LVL 35

Expert Comment

by:Paul MacDonald
ID: 35449176
@[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.
0
 
LVL 17

Expert Comment

by:Carlos Villegas
ID: 35449222
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.
0
 

Author Closing Comment

by:fjalbert
ID: 39745231
Thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

569 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