Saturday 7 July 2012

BulletedList

ASP.NET BulletedList control is used to create a list of items with bulleted format.You can set bulleted format as circle or rectangle and you can add items in bulleted list by using <asp:ListItem>.You can specify your bullet style by using BulleteStyle property.You can display your list of items in an organized or unorganized form.
How to Add Items Manually in BulletedLIst?
To add items manually in bulleted list, first double click on bulletedList control in toolbox.
After bulletedList is added into web page then click on the small tag on bulleted lis.then select Edit Items a new List Item Collection Editor box will appear.Now enter your item text that will appear in page and item's value.


How to Add Listitems programmatically?
You can add items programmatically by specifying the following at the server side.
At Client SIde:

    <asp:BulletedList ID="BulletedList1" runat="server">
        <asp:ListItem>Pakistan</asp:ListItem>
        <asp:ListItem>UK</asp:ListItem>
        <asp:ListItem>USA</asp:ListItem>
        <asp:ListItem>France</asp:ListItem>
    </asp:BulletedList>
At Server Side:
    protected void Page_Load(object sender, EventArgs e)
    {
        BulletedList1.Items.Add(new ListItem("Canada","Canada"));
        BulletedList1.Items.Add(new ListItem("Australia", "Australia"));
        BulletedList1.Items.Add(new ListItem("Russia", "Russian"));
        BulletedList1.Items.Add(new ListItem("Itly", "Itly"));
    }

How to display items from database?
To display list items from database simply provide the data source to the bulletedList control.To specify the data source to bulleted list first add you bulletedlist control into the web form and select it, a small tag will appear click on the small tag and select Choose Data Source option.
A new Data Source configuration wizard box.With the help of this box you can simply provide your data source.


How to specify bullets as Custom Image in BulletedList control?
You can specify the bullets as custom image in bulletedList by using the BulletIamageUrl property.
    <asp:BulletedList ID="BulletedList1" runat="server" 
        BulletImageUrl="~/bullet.png" BulletStyle="CustomImage" Width="71px">
        <asp:ListItem>Pakistan</asp:ListItem>
        <asp:ListItem>UK</asp:ListItem>
        <asp:ListItem>USA</asp:ListItem>
        <asp:ListItem>France</asp:ListItem>
    </asp:BulletedList>
How to display hyperlinks in BulledtedList control?
To display hyperlinks in bulleted list simply set DisplayMode is Hyperlink.
    <asp:BulletedList ID="BulletedList1" runat="server" 
        Width="71px" DisplayMode="LinkButton">
        <asp:ListItem Value="http://www.youtube.com/watch?v=gGiglVYd1b4">Pakistan</asp:ListItem>
        <asp:ListItem Value="http://www.youtube.com/watch?v=gGiglVYd1b4">UK</asp:ListItem>
        <asp:ListItem Value="http://www.youtube.com/watch?v=gGiglVYd1b4">USA</asp:ListItem>
        <asp:ListItem Value="http://www.youtube.com/watch?v=gGiglVYd1b4">France</asp:ListItem>
    </asp:BulletedList>
How to display LinkButton in BulledtedList control?
To display linkbutton in bullet list simpply set the Display property is linkButton.
   <asp:BulletedList ID="BulletedList1" runat="server" 
        Width="71px" DisplayMode="LinkButton">
        <asp:ListItem>Pakistan</asp:ListItem>
        <asp:ListItem>UK</asp:ListItem>
        <asp:ListItem>USA</asp:ListItem>
        <asp:ListItem>France</asp:ListItem>
    </asp:BulletedList>
 

1 comment:

  1. This is an amazingly helpful post with some really useful tips. Thank you for taking the time to write this up.

    Asp.net Development | C# Development

    ReplyDelete