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.
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.
Regarding the required field validator issue. I've opened a case and linked it to the development issue logged.You can view the status of the development issue connected to the case by selecting the "Development Issues" tab when viewing this case on the web site.
The selected value should return the Value of the selected item. Please refer to the attached sample and let me know if you notice any major difference in the approach or in the setup of the drop down.
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?
Thanks.
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?