Autopostback, binding and losing selection

  • Thread starter Thread starter sklett
  • Start date Start date
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
 
There is no way to do like your describing.
You should not bind again the dropdownlist in the postback event.
 
Back
Top