---
title: "ListBox in ASP.Net"  
description: "The List Box server control displays a list of items. We can select one or more items from the list of items displayed. The List Box control is used t"  
author: "Pushpendra Singh"  
published: 2010-10-13  
updated: 2019-09-07  
canonical: https://www.mindstick.com/articles/163/listbox-in-asp-dot-net  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 2 minutes  

---

# ListBox in ASP.Net

The List Box [server](https://www.mindstick.com/articles/43769/what-is-serverless-architecture-is-it-worth-switching-over) [control](https://yourviews.mindstick.com/view/83439/bipartisan-gun-control-bill-passed-in-us-after-decades) displays a list of items. We can [select](https://www.mindstick.com/forum/34066/use-select-operator-in-linq) one or more items from the list of items displayed. The List Box control is used to create a single- or multi-[selection](https://www.mindstick.com/blog/60/populate-records-in-second-listbox-according-to-the-selection-in-first-list-box) drop-down list.\

In single selection [ListBox](https://www.mindstick.com/articles/626/listbox-events-in-c-dot-net) we can select only single [value](https://www.mindstick.com/articles/23219/an-optimized-description-adds-value-to-experience-and-in-turn-effectively-guest-posting-packages) at a time.

In a multiple selection List Box we can select [multiple values](https://www.mindstick.com/forum/399/how-to-insert-multiple-values-selected-in-checkbox-in-database) at a time.

We can change selection mode by ListBox SelectionMode [Property](https://www.mindstick.com/articles/198559/an-ownership-of-property-in-hua-hin)

![ListBox Control in ASP.Net](https://www.mindstick.com/mindstickarticle/e2d98364-87fd-48cf-8b95-2d6d13eee52b/images/34b7e2ac-d237-42b2-b67e-91b5d4f51dd0.png)

## ListBox Event

SelectedIndexChanged Event: This event is fired when the selection of ListBox changes.

## Single Selection ListBox

```
<asp:ListBox ID="ListBox1" runat="server" AutoPostBack="True" Font-Bold="True"Font-Italic="True" ForeColor="#FF0066"         onselectedindexchanged="ListBox1_SelectedIndexChanged">         <asp:ListItem>Select</asp:ListItem>         <asp:ListItem>1</asp:ListItem>         <asp:ListItem>2</asp:ListItem>         <asp:ListItem>3</asp:ListItem>         <asp:ListItem>4</asp:ListItem>         <asp:ListItem></asp:ListItem>         <asp:ListItem>5</asp:ListItem>         <asp:ListItem></asp:ListItem> </asp:ListBox><asp:Label ID="Label1" runat="server"></asp:Label> protected void ListBox1_SelectedIndexChanged(object sender,  EventArgs e)    {         Label1.Text = ListBox1.SelectedValue;    }
```

![ListBox Control in ASP.Net](https://www.mindstick.com/mindstickarticle/e2d98364-87fd-48cf-8b95-2d6d13eee52b/images/443a7f83-6d24-48eb-bf81-ee41b5a4ffb9.png)

## Multiple Selection ListBox

To change the selection of ListBox from single selection to Multiple Selection you can set its SelectionMode property to Multiple.

```
          <asp:ListBox ID="ListBox1" runat="server" SelectionMode="Multiple">            <asp:ListItem>Select</asp:ListItem>            <asp:ListItem>1</asp:ListItem>            <asp:ListItem>2</asp:ListItem>            <asp:ListItem>3</asp:ListItem>            <asp:ListItem>4</asp:ListItem>            <asp:ListItem></asp:ListItem>            <asp:ListItem>5</asp:ListItem>            <asp:ListItem></asp:ListItem>         </asp:ListBox>       <asp:Button ID="Button1" runat="server" Text="Select" OnClick="Button1_Click" />     <asp:Label ID="Label1" runat="server"></asp:Label>         protected void Button1_Click(object sender, EventArgs e)    {         foreach (ListItem i in ListBox1.Items)         {            if (i.Selected)            {                Label1.Text += "<br>" + i.Value;            }         }      }
```

![ListBox Control in ASP.Net](https://www.mindstick.com/mindstickarticle/e2d98364-87fd-48cf-8b95-2d6d13eee52b/images/b67ac3de-4600-427f-99d1-302436f4811f.png)

## We can change List Box appearance

```
<asp:ListBox ID="ListBox1" runat="server" AutoPostBack="True" Font-Bold="True" Font-Italic="True" ForeColor="#FF0066" SelectionMode="Multiple">         <asp:ListItem>Select</asp:ListItem>         <asp:ListItem>1</asp:ListItem>         <asp:ListItem>2</asp:ListItem>         <asp:ListItem>3</asp:ListItem>         <asp:ListItem>4</asp:ListItem>         <asp:ListItem></asp:ListItem>         <asp:ListItem>5</asp:ListItem></asp:ListBox>
```

![ListBox Control in ASP.Net](https://www.mindstick.com/mindstickarticle/e2d98364-87fd-48cf-8b95-2d6d13eee52b/images/431888b6-61bc-44c4-a4da-1834835a510d.png)

---

Original Source: https://www.mindstick.com/articles/163/listbox-in-asp-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
