BulletedList Web Server Control Overview
The BulletedList control creates an unordered or ordered (numbered) list of items, which render as HTML ul or ol elements, respectively.
This topic contains:
Scenarios
Features
Background
How-to and Walkthrough Topics
Class Reference
Scenarios
Use the BulletedList control to do the following:
Specify the appearance of the items and of the bullets or numbers in a list.
Define the list items statically or by binding the control to data.
Respond to user clicks on items.
Back to top
Features
When using the BulletedList control, you can do the following:
Customize the appearance of the bullets and numbers.
Specify how each item in the list is rendered, such as a hyperlink, static text, or as a link button.
Provide logic to perform application-specific tasks when a user clicks an item.
Back to top
Background
The BulletedList control derives from the same ListControl class as the ListBox, DropDownList, and other ASP.NET list controls. Therefore, using the BulletedList control is like working with those controls. You can define list items for the BulletedList control either by creating static items or by binding the control to a data source. If you know at design time what items that you want to display, you can set the control's Items collection to a set of individual items in markup. If the items to be displayed are dynamic, you can create the item collection in code at run time. For details, see How to: Add Items in List Web Server Controls.
Alternatively, you can bind the control to a data source that contains the information that you want to display. For details, see How to: Populate List Web Server Controls from a Data Source.
You can combine static and data-bound list items by setting the control's AppendDataBoundItems property to true.
When you define items for the BulletedList control, you define two properties: the Text property and the Value property. The Text property defines what the control displays on the page. The Value property defines a second value that is not displayed but that you might want to return when a user selects an item. For example, you might display an employee name as the text of an item, but use the employee ID as the value. When users click the item, you can read the value directly.
Security Note: |
---|
Do not use sensitive data, such as customer numbers, for the value property of a BulletedList control. Even though it is not visible, the Value property settings of individual items are rendered to the page, where users can easily read them in the page's source. |
Customizing List Item Appearance
The BulletedList control can render either bullets or numbers, according to the setting of the BulletStyle property. If the control is set to render bullets, you can select from predefined bullet style fields that match HTML standard bullet styles, such as those represented by the Disc, Circle, and Square fields.
Note
Individual browsers vary in how they render bullets, and some browsers do not support certain bullet styles, such as the Disc field.
You can also specify a custom image that will be displayed instead of the bullet.
If the control is set to render numbers, you can select from HTML standard numbering options, such as the LowerAlpha, UpperAlpha, LowerRoman, and UpperAlpha fields. By setting the FirstBulletNumber property, you can also specify a starting number for the sequence.
Specifying Item Display Mode
The BulletedList control can display list items as any one of the following:
Static text The text displayed by the control is not interactive.
T:System.Web.UI.WebControls.HyperLink controls Users can click links to move to another page. You must provide a target URL as the Value property of individual items.
LinkButtoncontrols Users can click individual items and the control performs a postback.
Responding to User Selection
If the BulletedList control is configured to display individual items as LinkButton controls, the control performs a postback when a user clicks an item. The postback raises the BulletedList control's Click event, where you can provide logic to perform application-specific tasks. The event passes to you the index number of the item that was clicked. For details, see How to: Respond to User Clicks in BulletedList Web Server Controls.
How-to and Walkthrough Topics
How to: Add BulletedList Web Server Controls to a Web Forms Page
How to: Respond to User Clicks in BulletedList Web Server Controls
Class Reference
The following table lists the classes that relate to the BulletedList control.
Member |
Description |
---|---|
The main class for the control. |
|
An enumeration that specifies the display behavior of each item. |
|
The event data that indicates the index of the selected item. |
|
The method that handles the Click event of a BulletedList control. |
|
An enumeration that specifies the types of bullets, numbers, or letters that can be displayed. |
Back to top
See Also
Tasks
How to: Add Items in List Web Server Controls
How to: Populate List Web Server Controls from a Data Source