Is there a way to set the current display text and value of a webdropdown in the server-side(code behind vb file)?
Thanks,
Sunil Mehta.
Hi Sunil,
I have researched this issue and found that by handling the client-side ItemsRequested event for the child dropdown, I am able to set the selected item index and get the selected item displayed into the text editor of the child dropdown. This is how I approached this:
function child_ItemsRequested(sender, eventArgs)
{
var selectedIndex = sender.get_selectedItemIndex();
if (selectedIndex < 0)
selectedIndex = 0;
sender.set_currentValue("", true);
sender.set_selectedItemIndex(-1);
sender.set_activeItemIndex(-1);
sender.selectItemByIndex(selectedIndex, true, true);
}
function parent_SelectionChanged(sender, eventArgs)
var childDropDown = $find('<%=child.ClientID%>');
childDropDown.loadItems(eventArgs.getNewSelection()[0].get_value(), false);
I have attached the revised sample for your reference.
Please let me know if you need any additional assistance regarding this matter.
**Sample is attached. Please note that the ig_res folder has been omitted due to file size constraints. For proper styling of the grid you will want to add the ig_res folder. To do so, simple open the web form designer (aspx) and accept the styles when prompted
I have created a private case for you, for this issue. Please see the private support case for updates regarding this issue.
Thanks!
Hi Troy,
I did not have any intention of justifying whether SelectedItemIndex is showing expected behaviour or not. I just told you my problem and what I was trying to do. If this is expected behaviour, then please suggest me some other way to populate the INPUT of webdropdown from newly loaded items from server-side.
Hi SunilMehta,
I can confirm for you that when SelectedItemIndex (or SelectedValue) is set in code-behind, and its an ASYNC request (e.g., calling LoadItems from another dropdown), the text doesn't get updated. This is actually expected behavior.
The reason it is expected behavior is because load items only updates the the items list, not the whole control. Certainly not the input. The text can be manually updated after items are loaded and the state of the control is updated for the selected index or value.
SunilMehta, let me know if you need any additional assistance regarding this matter.
I do appreciate the urgency. I am pursuing information and working with our engineers to address the recommended approach for your objective. I am doing some further testing based on info from our engineers and will have an update for you on Thursday.
Thanks.