This tutorial will show you how to use the control of BulletedList to show data in ASP.NET and VB.NET 2.0. BulletedList class can create a control that generates a list of items in a bulleted format.
First, import the namespace of System.Web.UI.WebControls
| Imports System.Web.UI.WebControls |
We moved our web sites to Server Intellect and have found them to be incredibly professional. Their setup is very easy and we were up and running in no time.
We will use BulletedList1_Click event to show the selectedindex and selectedvalue.
|
Protected Sub BulletedList1_Click(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.BulletedListEventArgs) Handles BulletedList1.Click
Label1.Text = "SelectedIndex=" + e.Index.ToString() & ",Value=" & BulletedList1.Items(e.Index).Value
End Sub |
If you're looking for a really good web host, try Server Intellect - we found the setup procedure and control panel, very easy to adapt to and their IT team is awesome!
The front end Default.aspx page looks something like this:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>BulletedList Demo</title>
<link id="InstanceStyle" href="StyleSheet.css" type="text/css" rel="stylesheet" />
</head>
<body>
<form id="form1" runat="server">
<div>
<fieldset style="width: 400px">
<legend class="mainTitle">BulletedList Example</legend>
<br />
<asp:Label ID="Label1" runat="server" Font-Bold="true"></asp:Label>
<hr />
<table border="0" width="100%">
<tr align="center" style="text-decoration: underline;">
<td>
NotSet/Disc</td>
<td>
Numbered</td>
<td>
LowerAlpha</td>
</tr>
<tr>
<td>
<asp:BulletedList ID="BulletedList1" runat="server" AppendDataBoundItems="true" DataSourceID="AccessDataSource1"
DataTextField="PlaceTitle" DataValueField="RegionCode" DisplayMode="LinkButton"
OnClick="BulletedList1_Click">
<asp:ListItem Value="020">guangzhou</asp:ListItem>
<asp:ListItem Value="025">nanjing</asp:ListItem>
</asp:BulletedList>
</td>
<td>
<asp:BulletedList ID="BulletedList2" runat="server" AppendDataBoundItems="true" DataSourceID="AccessDataSource1"
DataTextField="PlaceTitle" DataValueField="RegionCode" DisplayMode="Text" BulletStyle="Numbered">
<asp:ListItem Value="020">guangzhou</asp:ListItem>
<asp:ListItem Value="025">nanjing</asp:ListItem>
</asp:BulletedList>
</td>
<td>
<asp:BulletedList ID="BulletedList3" runat="server" AppendDataBoundItems="true" DataSourceID="AccessDataSource1"
DataTextField="PlaceTitle" DataValueField="RegionCode" DisplayMode="Text"
BulletStyle="LowerAlpha">
<asp:ListItem Value="020">guangzhou</asp:ListItem>
<asp:ListItem Value="025">nanjing</asp:ListItem>
</asp:BulletedList>
</td>
</tr>
</table>
</fieldset>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/CityData.mdb"
SelectCommand="SELECT PlaceTitle,RegionCode FROM [SupperCity]"></asp:AccessDataSource>
</div>
</form>
</body>
</html>
|
We are using Server Intellect and have found that by far, they are the most friendly, responsive, and knowledgeable support team we've ever dealt with!
The flow for the code behind page is as follows.
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub BulletedList1_Click(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.BulletedListEventArgs) Handles BulletedList1.Click
Label1.Text = "SelectedIndex=" + e.Index.ToString() & ",Value=" & BulletedList1.Items(e.Index).Value
End Sub
End Class
|
Download the Full Working Version of this Project written with Visual Studio.NET VB.NET 2005 Here!
Looking for the C#.NET 2005 Version? Click Here!
Looking for more ASP.NET Tutorials? Click Here!