Click here to Skip to main content
15,905,322 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am trying to set value to raddropdownlist using javascript.

What I have tried:

JavaScript
  var dropdownlist = $find("<%= rcbLayout.ClientID %>");
  var item = dropdownlist.findItemByText(rlvControllers._dataSource[itemIndex].FORMLAYOUT);
item.select();


markup:

ASP.NET
<asp:Label ID="LayoutLabel" runat="server" Text="Form Layout:"></asp:Label>
<telerik:RadDropDownList RenderMode="Lightweight" ID="rcbLayout" Width="250px" DataTextField="TEXT" DataValueField="VALUE" runat="server"></telerik:RadDropDownList>
Posted
Updated 15-Nov-18 5:52am

1 solution

According to the documentation, you can use select() or set_selected(true) function.

Looking at your code, it seems like your are doing it right. You just have to make sure that the value of rlvControllers._dataSource[itemIndex].FORMLAYOUT that you passed in the findItemByText() method exist in your dropdownlist DataTextField or else it won't work. One thing to note that you could also use the findItemByValue() method if you want to select the value based on the dropdownlist DataValueField.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900