ASP.NET - List Control - Bullet List

A bulleted list in ASP.NET is a control that presents a list of items, where each item is preceded by a bullet point or other symbol. Bulleted lists are commonly used to present a series of related items, such as a list of products, services, or features.

Events:

  • DataBinding: This event is triggered when the data for the bulleted list is bound to a data source.
  • ItemCommand: This event is triggered when the user clicks on an item in the bulleted list.

Methods:

  • Add: Adds a new item to the bulleted list.
  • Clear: Removes all items from the bulleted list.
  • FindByText: Finds the item with the specified text in the bulleted list.
  • FindByValue: Finds the item with the specified value in the bulleted list.

Properties:

  • DataSource: Gets or sets the data source for the bulleted list.
  • DisplayMode: Gets or sets the display mode for the bulleted list (static or dynamic).
  • BulletStyle: Gets or sets the style for the bullet points in the bulleted list.
  • Items: Gets a collection of all the items in the bulleted list.

Example

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="BulletedListExample.aspx.cs" Inherits="WebApplication1.BulletedListExample" %>
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Product Features</title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <h2>Product Features</h2>
            <asp:BulletedList ID="FeatureList" runat="server" DisplayMode="Static">
                <asp:ListItem Text="Easy to use interface" />
                <asp:ListItem Text="Fast and reliable performance" />
                <asp:ListItem Text="Wide range of customization options" />
                <asp:ListItem Text="Great customer support" />
            </asp:BulletedList>
        </div>
    </form>
</body>
</html>

In the code-behind file, we can add new items to the bulleted list using the Add method:

using System;
namespace WebApplication1
{
    public partial class BulletedListExample : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            FeatureList.Items.Add(new ListItem("Mobile-friendly design"));
            FeatureList.Items.Add(new ListItem("Integrates with popular platforms"));
        }
    }
}