We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Generic Dropdown

Hi,

I am looking to add items in generic dropdown and change the selected value on runtime, but I didn't see any suitable property for the same.

Please let me guide how I can achieve it.

Thanks
Nitin


9 Replies

VR Varalakshmi R.S Syncfusion Team April 25, 2011 01:02 PM UTC

Hi Nitin,

Thanks for your interest in syncfusion products.

If your intention is to highlight the selected item in the items added to the GenericDropDownControl then it can be achieved by enabling the selected property of the corresponding item. Here we have created a simple sample for adding TreeView in GenericDropDown control and by default the items with value 7 will be selected then during run time the item will be highlighted based on the items selected. Please find the below code snippet to achieve this,

[VB]
Protected Sub tree_NodeSelected(ByVal sender As Object, ByVal e As Syncfusion.Web.UI.WebControls.Tools.TreeViewNodeSelectEventArgs)
GenericDropDown1.Text = TreeView1.SelectedNode.Text //displays the selected item text in GenericDropDown1
End Sub

Protected Sub TreeView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles TreeView1.DataBound
findValue(TreeView1.Items)
End Sub
Protected Sub findValue(ByVal items As TreeViewItemCollection)
For Each item As TreeViewNode In items
If (item.Value.Equals("7")) Then
item.Selected = True //highlight the item which has the value “7”
GenericDropDown1.Text = item.Text
End If
If (item.HasSubNodes) Then
findValue(item.Items)//this continues recursively to highlight the items
End If
Next

End Sub


Kindly download the sample from the following link,
generic-760246203.zip

Please try the sample and let us know if this helps.

Regards,
Varalakshmi R.S




CT Chetan Thummar June 21, 2011 10:07 AM UTC

Hello,

I have code to display checkbox list in dropdown as your sample application.

its nice and bind properly what i want.

but there is problem with checked items in dropdown that cant get the value of checked items and i want to pass it to controller.

how to do same?????

please solve this problem.....
thanks in advance....



VI Vignesh Syncfusion Team June 22, 2011 08:37 AM UTC

Hi Nitin,

Before we providing you a solution, could you please confirm with us that is your requirement in MVC?. So that we could able to provide you a better solution.

Please let us know your concerns.

Regards,
Vignesh



CT Chetan Thummar June 25, 2011 06:10 AM UTC

Hi,

Chetan here and sure that i m using MVC so please give me a solusin in MVC...

Thank you.



CT Chetan Thummar June 25, 2011 06:12 AM UTC

Hi,

Chetan here and sure that i m using MVC so please give me a solusin in MVC...

Thank you.



CT Chetan Thummar June 25, 2011 06:12 AM UTC

Hi,

Chetan here and sure that i m using MVC so please give me a solusin in MVC...

Thank you.



VI Vignesh Syncfusion Team June 27, 2011 11:24 AM UTC

Hi Chetan,

Thanks for the Update.

To send the selected value from the drop down to the controller use the following code to achieve it.


[Javascript]
$.ajax({
type: 'Post',
data: { input: selText },
dataType: "json",
success: function (result) {

obj.setText(result.input);
}

});



Also I have created a simple sample and attached in the below link for your reference,

GenericDropDown-259114197.zip

Please try this and let us know if you have any queries.

Regards,
Vignesh




CT Chetan Thummar June 28, 2011 05:33 AM UTC

Thank you very much for solve my problem.




VI Vignesh Syncfusion Team June 28, 2011 06:48 AM UTC

Hi Chetan,

Thanks for the Update.

Please let us know if you have any other queries. We will happy to help you out.

Regards,
Vignesh


Loader.
Live Chat Icon For mobile
Up arrow icon