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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to retrieve the selected value from server-side event in the DropDownList control?

Platform: ASP.NET Web Forms |
Control: DropDownList |
Published Date: January 31, 2015 |
Last Revised Date: May 8, 2019 |
Product Version: 12.4.0.24

Get selected item in DropDownList from server-side

To get the selected item value of the DropDownList control on the post back, use the server-side OnValueSelect event of the DropDownList, so that you can access the DropDownList data in the code behind. The OnValueSelect server-side event triggers the post back when the value of the DropDownList item is changed and maps to the corresponding event handler in the code behind. In the server-side event handler, you can access the value, ID, text, and checked state details by using the DropdownListEventArgs variable. Refer to the following code example.

 

ASPX

<ej:DropDownList ID="DropDownList1" runat="server" DataValueField="ParentId" DataTextField="Text" OnValueSelect="DropDownList1_ValueSelect"> </ej:DropDownList>

 

CodeBehind

protected void DropDownList1_ValueSelect(object sender, Syncfusion.JavaScript.Web.DropdownListEventArgs e)
   {
        string text = e.SelectedText;
       //SelectedText - Gets the text of the selected item.
       //Value - Gets the value of the selected item.
       //ItemId - Gets the ID of the selected item.
       //IsChecked - Gets the checked status to true or false when check boxes are enabled.
   }

 

2X faster development

The ultimate ASP.NET Web Forms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment
Comments
Ryan How
Feb 11, 2015
I've tried this code, but the server side event is never executed. The page simply reloads. The event is hooked up because if I change the method names then I get exceptions. I can however read the value of DropDownList1.Value to get the selected value in other methods. Reply
Ezhil S [Syncfusion]
Feb 11, 2015
Hi Ryan, Yes, You can get the values using the DropDownList properties in code behind. Same way you can also get the DropDownList Value details using OnValueSelect event arguments. We are unable to reproduce the reported issue with the details provided by renaming the Event name.Please check the online sample demo link: http://asp.syncfusion.com/demos/web/dropdownlist/event.aspx We have also attached sample that works fine. Modify our sample or attach defect sample to check the issue. Sample link: http://www.syncfusion.com/downloads/support/directtrac/general/Menu_135192-671257844.zip Kindly let us know if you have further queries. Regards, Ezhil S Reply

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon