ASP.NET BulletedList control is the server-side equivalent of the <ul> (unsorted list) or <ol> (ordered list) elements. As with all list controls, you have to use the Items property to set the collection of items that should be displayed. The next table lists additional properties you can use to configure how the items are displayed:
Property |
Description |
BulletStyle |
The property specifies the type of list. You can choose from Numbered (1, 2, 3…), LowerAlpha (a,b, c…) and UpperAlpha (A, B, C…), LowerRoman (i, ii, iii…) and UpperRoman (I,II, III…), and the bullet symbols Disc, Circle, Square, or CustomImage (in which case you must set the BulletImageUrl property). |
BulletImageUrl |
If the BulletStyle is set to CustomImage, this points to the image that is placed to the left of each item as a bullet. |
FirstBulletNumber |
In an ordered list (using the Numbered, LowerAlpha, UpperAlpha,LowerRoman, or UpperRoman styles), this sets the first value. For example, if you set FirstBulletNumber to 3, the list might read 3, 4, 5 (for Numbered) or C,D, E (for UpperAlpha). |
DisplayMode |
Determines whether the text of each item is rendered as text (use Text, the default) or a hyperlink (use LinkButton or HyperLink). The difference between LinkButton and HyperLink is how they treat clicks: – When you use LinkButton, the BulletedList fires a Click event that you can react to on the server to perform the navigation. – When you use HyperLink, the BulletedList doesn’t fire the Click event—instead, it treats the text of each list item as a relative or absolute URL, and renders them as ordinary HTML hyperlinks. When the user clicks an item, the browser attempts to navigate to that URL. |
The next code lines show the case if you choose to set the DisplayMode to LinkButton. In this case you can react to the Click event to determine which item is clicked:
In C#
protected void BulletedList1_Click(object sender, BulletedListEventArgs e)
{
string itemText = BulletedList1.Items[e.Index].Text;
Label1.Text = “You choose item” + itemText;
}
In VB.NET
Protected Sub BulletedList1_Click(sender As Object, e As BulletedListEventArgs)
Dim ItemText As String = BulletedList1.Items(e.Index).Text
Label1.Text = “You choose item” & itemTextEnd
Sub