Autopostback, binding and losing selection

S

sklett

Hi-

I'm a bit rusty cause it's been awhile since I've made an asp.net app, but
here is what I want to do:

single aspx page
bound DropDownList w/ autopost back that holds names of customers
DataGrid that shows customer data

When a user selects a customer from the drop down, I get the selected
value(customer ID) and store it into a member variable (mCustId) then I call
my BindData() method that uses that CustId to filter a DataTable and show
the correct data for that customer.

Everything works except when the Autopostback fires, I don't have the
correct selection in the DropDownList. This is because I'm calling
BindData() which also binds the DropDownList.

The problem is obvious and a basic solution is also obvious (call separate
function just to bind the grid) but this does not seem like a very flexible
solution. Is there some way to make the DropDownList's selectedItem value
persist?

Based on what I have described here(this MUST be a common approach) what is
the standard way to handle this?

Thanks for any tips or help!


Steve
 
S

SHENG333

There is no way to do like your describing.
You should not bind again the dropdownlist in the postback event.
 

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,773
Messages
2,569,594
Members
45,114
Latest member
GlucoPremiumReview
Top