Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
830
WebDropDown SelectedValue on Server
posted

Hi,

I have a WebDropDown inside an updatepanel. The DataSource is bound as expected to a BindingList of Entities:

this.NullText = "Select a Field"

this.WebDropDown1.DataSource = this.GetEntityList();

this.WebDropDown1.TextField = "Description"

this.WebDropDown1.ValueField = "ID"

this.WebDropDown1.DataBind();

The SelectedValue property is not bound to any data nor setted to an initial value.

The control is displayed and works. We can see "Select a Field" and choose any other item.

The first thing I noticed is that the RequiredFieldValidator linked to the control, does not work. If I submit the form and no item is selected in the WebDropDown, the form is submitted and no validation is performed.

The second issue is that at server side I cannot see the Selected value.

I want to set the value to a data field:

this.User.CountryID = this.WebDropDown.SelectedValue

A NullReferenceException is thrown.

Debugging There is no SelectedItem, Items is empty. It seems that datalist is not binding properly.

Any Idea of what is happening?

Thanks in advance