dropdown - autopostback
Hi,
I'm developing my first user control to integrate with Sitefinity 4.0.
- I have one dropdown with AutoPostBack=true
- In page load i bind that dropdown if IsPostBack=false
- When i select one value i loose the dropdown state and it becames an empty dropdwon.
I verified the EnableViewState Property and it's true.
What am i doing wrong ?
I'm having similar problems with data bound dropdowns. I spent the last two days trying to get my first form to save without the lists being emptied during the post back causing validation to fail. Seems to be related to viewstate, but I tried everything to enable it with no luck. I decided to try reloading the lists during the postback. My final solution: bind the lists during the OnInit event. I usually use the OnLoad but it seems that's too late in the lifecycle. I only bind the DataSource in the OnInit, and set the SelectedValue only during the full DataBind that happens on load.
Hello Joana and Matt,
There indeed are problems with the Page's view state and the life cycle. By default the page's view state is not enabled and should be done through code. You can achieve this from the master page:
protected
override
void
OnInit(EventArgs e)
this
.Page.EnableViewState =
true
;
base
.OnInit(e);
it worked.
thanks