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
Hello t0rren1e ,
Thank you for posting in our forum.
Could you let me know which version of our controls and which service release you’re currently using?
I’m looking forward to your reply.
Best Regards,
Maya Kirova
Developer Support Engineer
Infragistics, Inc.
http://es.infragistics.com/support
Hi Maya,
Thanks for your early response.
I´m using the latest release 12.1.20121.2072 of the ASP .NET controls.
Hello t0rren1e,
Thank you for the information.
The issue with the validator seems to be a development issue in 12.120121.2072. I’ll log it and let you know the development issue number so that you may follow up on its progress.Regarding the selected value. If you try to access this before you call databind on the drop down it will be available. However if you call it after that it will be empty. If you need to get the value after data binding you can handle the SelectionChanged event of the drop down and get the new selected index with: e.NewSelection.
Let me know if you have any questions.
I think thta you are telling me to fire a server event after a selection has changed. I don´t want this behavior.
I want the user to select his aproppiate value at the client side and then, when submitting, at server side code-behind, get the selectedvalue.
Right now at server side in the submit button click code-behind I can see the CurrentValue and the ActiveItemIndex but the Selectedvalue fires a NullReference Exception.
Is it a Way to change the SelectedValue on the client side whenever a selection is changed?
Thanks.
I found the main error, the form had his EnableViewState set to false. I changed it and then I can see at server side the SelectedValue and the SelectedItem.
There is a new issue, the SelectedValue is the TextField and not the ValueField as I expected.
How can I retrieve the ValueField?
I’ve received a response from the development team. It seems that it’s needed when you have a NullText set for the webdropdown that you set the same text for the RequiredFieldValidator’s InitualValue property in order for it to work as expected. Please refer to the attached sample and let me know if you have any questions.