Category / Section
How to retrieve the selected value from server-side event in the DropDownList control?
1 min read
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. }