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.
LinkButton controls Users can click individual items and the control performs a postback.
Responding to User Selection