Articles in this section
Category / Section

How to clear the selected items in DropDownList from server side?

1 min read

To clear selected items in the ASP.NET Web Forms DropDownList from sever side, we can use the ClearSelection method. This method clears all the selected values. Refer to the following code.

[CS]

protected void btn1_Click(object sender, EventArgs e)
{
    this.selectCar.ClearSelection();
}

 

[ASPX]

<ej:DropDownList ID="selectCar"   ShowCheckbox="true" runat="server">
</ej:DropDownList>

 

Otherwise, the selected items can also be removed using any of the following properties.

Clearing the selection by setting SelectedIndex property to -1

[CS]

protected void btn1_Click(object sender, EventArgs e)
{
    this.selectCar.SelectedIndex = -1;
}

 

Clearing the selected value by setting an empty string to Value property

[CS]

protected void btn1_Click(object sender, EventArgs e)
{
    this.selectCar.Value = "";
}

 

Clearing the selected text by setting an empty string to Text property

[CS]

protected void btn1_Click(object sender, EventArgs e)
{
    this.selectCar.Text = "";
}

 

Conclusion

I hope you enjoyed learning about how to clear the selected items in DropDownList from server side.

You can refer to our ASP.NET Web Forms DropDownList’s feature tour page to know about its other groundbreaking feature representations. You can also explore our ASP.NET Web Forms DropDownList example to understand how to present and manipulate data. 

For current customers, you can check out our ASP.NET Web Forms from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our ASP.NET Web Forms DropDownList and other ASP.NET Web Forms components.

If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied