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:
- Create a new ASP.NET Empty WebSite project.
Give project name: BulletedList
- Right click on project,
Add, Add New Item, then click Web Form
Give file name Default.aspx
- Open your WEB.CONFIG file and set connection strings.
- <connectionStrings>
- <add name="BLConnectionString" connectionString="Data Source=SAIBABA-PC\SAIBABA;Initial Catalog=MemberCDAC;Integrated Security=True" providerName="System.Data.SqlClient" />
- </connectionStrings>
Table Structure:
- /****** Object: Table [dbo].[tblFriends] Script Date: 02/17/2016 11:05:19 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- SET ANSI_PADDING ON
- GO
- CREATE TABLE[dbo].[tblFriends]
- (
- [FriendID][int] IDENTITY(1, 1) NOT NULL, [Name][varchar](50) NULL, [Place][varchar](25) NULL, [Mobile][varchar](15) NULL, [EmailAddress][varchar](150) NULL
- ) ON[PRIMARY]
- GO
- SET ANSI_PADDING OFF
- GO
- Drag and drop bulleted list control on the default.aspx page.
- Press right click on bulleted list control and see property,
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
- DEFAULT.ASPX code
- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml">
-
- <head runat="server">
- <title></title>
- </head>
-
- <body>
- <form id="form1" runat="server">
- <div>
- <h2>Example of BulletStyle = <b>NotSet</b></h2>
- <asp:BulletedList ID="BulletedList1" runat="server">
- </asp:BulletedList>
- </div>
- </form>
- </body>
-
- </html>
- DEFAULT.ASPX.CS code behind
- using System;
- using System.Collections.Generic;
- using System.Configuration;
- using System.Data;
- using System.Data.SqlClient;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- public partial class _Default: System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- string constr = ConfigurationManager.ConnectionStrings["BLConnectionString"].ConnectionString;
- DataSet frndDataSet = new DataSet();
- SqlConnection con = new SqlConnection(constr);
- SqlDataAdapter da = new SqlDataAdapter("Select * From tblFriends", con);
- da.Fill(frndDataSet, "FriendDataTable");
- BulletedList1.DataTextField = "Name";
- BulletedList1.DataSource = frndDataSet.Tables["FriendDataTable"].DefaultView;
- BulletedList1.DataBind();
- }
- }
- Example of Bullet Style,
BulletStyle = NotSet
BulletStyle = Numbered
BulletStyle = LowerAlpha
BulletStyle = UpperAlpha
BulletStyle = LowerRoman
BulletStyle = Disc
BulletStyle = Circle
BulletStyle = Square
BulletStyle = CustomImage
BulletImageUrl="~/index.jpg"
Read more articles on ASP.NET: