• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 222
  • Last Modified:

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

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
fjalbert
Asked:
fjalbert
  • 4
  • 3
  • 2
1 Solution
 
Paul MacDonaldDirector, Information SystemsCommented:
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
 
fjalbertAuthor Commented:
I am posting back to the same page with a new parameter to open another record with in my form.
0
 
Paul MacDonaldDirector, Information SystemsCommented:
...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
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

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

0
 
fjalbertAuthor 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.  
0
 
Carlos VillegasFull Stack .NET DeveloperCommented:
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
 
Paul MacDonaldDirector, Information SystemsCommented:
@[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
 
Carlos VillegasFull Stack .NET DeveloperCommented:
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
 
fjalbertAuthor Commented:
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

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