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 Troy,
Yes, i am using the Cascading Webdropdown functionality. I am using two webdropdowns "webdropdown1" and "webdropdown2". Based upon the selection change in webdropdown1, values in webdropdown2 will be loaded.
Here is the client-side code in BLOCKED SCRIPT
function Fillwebdropdown2(sender, e) {
var loadValue = e.getNewSelection()[0].get_value();
$find("webdropdown2").loadItems(loadValue,false);
}
The above function is called when a selectionChanged event is triggered on "Webdropdown1".
Code-snippet in server-side:(VB.NET):
Protected Sub webdropdown2_OnItemsRequested(ByVal sender As Object, ByVal e As Infragistics.Web.UI.ListControls.DropDownItemsRequestedEventArgs)
Dim CoEntry As Integer
webdropdown2.Items.Clear()
webdropdown2.Items.Add(New Infragistics.Web.UI.ListControls.DropDownItem("", ""))
Then, logic to load the items from database to webdropdown2. Then,
CoEntry = webdropdown2.Items.IndexOf(webdropdown2.Items.FindItemByValue("0122"))
If CoEntry > 0 Then
webdropdown2.SelectedItemIndex = CoEntry
webdropdown2.CurrentValue = webdropdown2.Items(CoEntry).Text
webdropdown2.ValueField = webdropdown2.Items(CoEntry).Value
webdropdown2.TextField = webdropdown2.Items(CoEntry).Text
End if
End Sub
The values are getting loaded successfully in 'webdropdown2". But I am not able to select a value through the above code.
Hi SunilMehta,
Can you show me your code snippets? I'd like to see your ItemsRequested server side code and the client side event code that calls the LoadItems method.
As you are taking this approach I am wondering if you are doing soemthing with cascading WebDropDown providers, where one drop down provider serves as a filter for another WebDropDownProvider??
If you can offer some clarification on this I can better understand your objectives.
I have a similar code in the page_load function and it works fine. But now, I have this code in a function called on "OnItemsRequested" server-side event. This event is being called when "loadItems" function on client-side is executed.
Why the similar code snippet does not work in the function called on "OnItemsRequested" event.
Looking further into this I am not actually sure of the reason you are unable to see the text for the index in the WebDropDown.
I have taken the example Jon descibes above and turned it into a running sample that you can work with. Upon viewing the sample let me know if you are unable to see the "text" of the index value shown in the dropdown.
Let me know if I can be of further assistance.
*Sample attached. Please note that the ig_res folder has been omitted due to file size constraints. For proper styling of the dropdown you will want to add the ig_res folder. To do so, simpley open the web form designer (aspx) and accept the styles when prompted.
Hi Jon,
Still, I am not able to set the display item of the webdropdown from Code-behind VB file. I feel this is a very simple option that I am asking. Can you please help me out in this?