How To Use Bulleted List Control In ASP.NET

We use this control for dynamically displaying a bullet list on a web page. You can set 10 different types of bulleted item on list items.

Sample of a bullet list is given below:

  • Rajesh
  • Mahesh
  • Suresh
  • Ramesh
  1. Create a new ASP.NET Empty WebSite project.

    project

    Give project name: BulletedList

  2. Right click on project,

    project

    Add, Add New Item, then click Web Form

    web form

    Give file name Default.aspx

  3. Open your WEB.CONFIG file and set connection strings.
    1. <connectionStrings>  
    2.     <add name="BLConnectionString" connectionString="Data Source=SAIBABA-PC\SAIBABA;Initial Catalog=MemberCDAC;Integrated Security=True" providerName="System.Data.SqlClient" />  
    3. </connectionStrings>  
    Table Structure:
    1. /****** Object: Table [dbo].[tblFriends] Script Date: 02/17/2016 11:05:19 ******/  
    2. SET ANSI_NULLS ON  
    3. GO  
    4. SET QUOTED_IDENTIFIER ON  
    5. GO  
    6. SET ANSI_PADDING ON  
    7. GO  
    8. CREATE TABLE[dbo].[tblFriends]  
    9.     (  
    10.         [FriendID][int] IDENTITY(1, 1) NOT NULL, [Name][varchar](50) NULL, [Place][varchar](25) NULL, [Mobile][varchar](15) NULL, [EmailAddress][varchar](150) NULL  
    11.     ) ON[PRIMARY]  
    12. GO  
    13. SET ANSI_PADDING OFF  
    14. GO  
    table

  4. Drag and  drop bulleted list control on the default.aspx page.

    list

  5. Press right click on bulleted list control and see property,

    properties

    You can set the following types of Bulleted Control:

    a. Circle
    b. CustomImage
    c. Disc
    d. LowerAlpha
    e. LowerRoman
    f. NotSet
    g. Numbered
    h. Square
    i. UpperAlpha
    j. UpperRoman

  6. DEFAULT.ASPX code
    1. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>  
    2.     <!DOCTYPE html>  
    3.     <html xmlns="http://www.w3.org/1999/xhtml">  
    4.   
    5.     <head runat="server">  
    6.         <title></title>  
    7.     </head>  
    8.   
    9.     <body>  
    10.         <form id="form1" runat="server">  
    11.             <div>  
    12.                 <h2>Example of BulletStyle = <b>NotSet</b></h2>  
    13.                 <asp:BulletedList ID="BulletedList1" runat="server">  
    14.                 </asp:BulletedList>  
    15.             </div>  
    16.         </form>  
    17.     </body>  
    18.   
    19.     </html>  
  7. DEFAULT.ASPX.CS code behind
    1. using System;  
    2. using System.Collections.Generic;  
    3. using System.Configuration;  
    4. using System.Data;  
    5. using System.Data.SqlClient;  
    6. using System.Linq;  
    7. using System.Web;  
    8. using System.Web.UI;  
    9. using System.Web.UI.WebControls;  
    10. public partial class _Default: System.Web.UI.Page   
    11. {  
    12.     protected void Page_Load(object sender, EventArgs e)  
    13.     {  
    14.         string constr = ConfigurationManager.ConnectionStrings["BLConnectionString"].ConnectionString;  
    15.         DataSet frndDataSet = new DataSet();  
    16.         SqlConnection con = new SqlConnection(constr);  
    17.         SqlDataAdapter da = new SqlDataAdapter("Select * From tblFriends", con);  
    18.         da.Fill(frndDataSet, "FriendDataTable");  
    19.         BulletedList1.DataTextField = "Name";  
    20.         BulletedList1.DataSource = frndDataSet.Tables["FriendDataTable"].DefaultView;  
    21.         BulletedList1.DataBind();  
    22.     }  
    23. }   
  8. Example of Bullet Style,

    BulletStyle = NotSet

    notset

    BulletStyle = Numbered

    Numbered

    BulletStyle = LowerAlpha

    LowerAlpha

    BulletStyle = UpperAlpha

    UpperAlpha

    BulletStyle = LowerRoman

    LowerRoman

    BulletStyle = Disc

    Disc

    BulletStyle = Circle

    Circle

    BulletStyle = Square

    Square

    BulletStyle = CustomImage

    BulletImageUrl="~/index.jpg"

    Square

Read more articles on ASP.NET:


Similar Articles