- Remove an item by index from a DropDownList

DropDownList Items.RemoveAt() method
dropdownlist control hold a collection of list items. user can select a single item from dropdownlist. each list item can have display text and it's associated value. we can remove dropdownlist list item from it's item collections. the following example show you how can we remove (delete) dropdownlist list item from specific index position by it's index number.

dropdownlist RemoveAt method (function) allow us to remove any item from collection by it's index number. dropdownlist server control's list item index start from zero (0). so if you want to remove first item from dropdownlist then pass the index value 0 to the RemoveAt function. or you want to delete any other item from dropdownlist then pass the specific index number to the RemoveAt method. run this source code on visual studio IDE and try to understand how the RemoveAt method work.

<%@ Page Language="C#" %>

<!DOCTYPE html>

<script runat="server">
    protected void Button1_Click(object sender, System.EventArgs e) {
        int myNumber = Convert.ToInt32(TextBox1.Text);
        Label1.Text = "Item removed from index number: " +

<html xmlns="">
<head id="Head1" runat="server">
    <title> DropDownList Items.RemoveAt() example: how to remove item by index number</title>
    <form id="form1" runat="server">
        <h2 style="color:Red">DropDownList Items.RemoveAt() example</h2>
        <asp:Label ID="Label1" runat="server" Font-Bold="true" ForeColor="BlueViolet"></asp:Label>
        <br />
        <asp:DropDownList ID="DropDownList1" runat="server">
        <br /><br />
        <b style="color:Green">Index start from 0</b>
        <br />
        <asp:Label ID="Label2" runat="server" Text="Position[Index]" AssociatedControlID="TextBox1"></asp:Label>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" Text="*"></asp:RequiredFieldValidator>
        <br />
        <asp:Button ID="Button1" runat="server" Text="Remove Item" OnClick="Button1_Click" />
More examples