Bulletedlist control are used to generates a list of items in a bulleted format.
Bulletedlist control inherited from :
Object->Control->WebControl->BaseDataBoundControl->DataBoundControl->ListControl->BulletedList
Example of bulleted list :
Create the web form and add the following code.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<h3>BulletList Data Binding Example</h3>
<asp:BulletedList ID="BulletedList1" runat="server">
<asp:ListItem Value="1">One</asp:ListItem>
<asp:ListItem Value="2">Two</asp:ListItem>
<asp:ListItem Value="3">Three</asp:ListItem>
</asp:BulletedList>
<h3>Click on an item in the list.</h3>
<asp:BulletedList ID="BulletedListId"
runat="server" DisplayMode="LinkButton" OnClick="BulletedListId_Click">
<asp:ListItem Value="Sunday">Sunday</asp:ListItem>
<asp:ListItem Value="Monday">Monday</asp:ListItem>
<asp:ListItem Value="Tuseday">Tuseday</asp:ListItem>
</asp:BulletedList>
<asp:Label id="lblMessage"
Font-Size="12"
Width="168px"
Font-Bold="True"
runat="server"
AssociatedControlID="BulletedListId"/>
</form>
</body>
</html>
Add the following code in c# code behind page :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Tutoral_1
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void BulletedListId_Click(object sender, BulletedListEventArgs e)
{
switch (e.Index)
{
case 0:
lblMessage.Text = "You clicked on Sunday.";
break;
case 1:
lblMessage.Text = "You clicked on Monday.";
break;
case 2:
lblMessage.Text = "You clicked on Tuseday.";
break;
default:
lblMessage.Text = "";
throw new Exception("You did not click a valid list item.");
break;
}
}
}
}
Output :
For more information about bullet list click Here
No comments:
Post a Comment