I have found so many examples about binding to a JSON string (which I'm using and it works perfect) but what I can't figure out how to do is retrieve the unique VALUE of a selected row, not the text. I'm binding to a JSON string that is generated from grabbing a simple primary key/item id/description set from sql server. This works fine when binding the drop down to a sqldatasource. You can set the TextField and ValueField and you can grab both when posting back. You can get the text of the element by looking at the .CurrentValue (which is confusing; why not .Text or even .CurrentText) and you can get the value by looking at .SelectedValue.Now when I bind to this dropdown via a JSON string in javascript and then post back, I can get the text (.CurrentValue) but not the value (.SelectedValue). Even though I'm setting both the TextField and ValueField in the html to the corresponding names in the JSON string.
How can I bind the drop down in javascript to a JSON string, display only the ID and Description (which I currently have working using a client template), but then grab the VALUE after making a selection or posting back?
Hello IanLudwig ,
Thank you for posting in our forum.
Generally if you set the data source and bind the drop down only on the client the drop downs items collection would be empty on the server side.In the selection changed event you can get the new selected index: e.NewSelection but since the items collection is empty there will be no item associated with that index and the selected item would be null. The current value is the value that is passed from the input element of the webdropdown so it will contain only the selected text.
So you cannot get the value from the server side in such a scenario directly from the drop down. If you can get the json data on the server side then you could check the value field at the selected index of the drop down.
Let me know if you have any questions or concerns regarding this.
Best Regards,
Maya Kirova
Developer Support Engineer
Infragistics, Inc.
http://ko.infragistics.com/support