New Message on dotNET User Group Hyd

ASP.NET 2.0 -- Standard Controls - Bulleted List (04-09-2006)

Reply
  Reply to Sender   Recommend Message 1 in Discussion
From: Nasha

Hi All,

Today we will discuss the Bulleted List Control.

Bulleted List is a new control that is added to the list of standard controls on ASP.NET 2.0. Bulleted List, the name

suggests that this control is used to dispplay a list of unordered items but using it you can also display a list of ordered

items. You need to set the BulletStyle property to display data in different formats. The default value of this is "Not Set".

1. Let us open a new project and drag and drop this control on the page. You will see BulletedList Tasks, Choose DataItems

and Edit Items context menu besided the UNBOUND control.

2. Let us now go to the properties and explore the Bullet Style property under APPEARANCE category. You can see various

values for it in the drop down. Try and change the value of this property from "NOT SET" to any other value in the list.

Please note that on selection of any other value like "LOWER ALPHA" , "UPPER ALPHA" etc the change in display is visible at

DESIGN TIME.

3. Now let us select the value of Bullet Style as Custom Image. Along with that we even need to set the value of a property

just above it called as BulletImageURL. Add an image to the project from the file system and click on the ellipsis and select

the image. You can see the image is used as a bullet. You can view these changes at DESIGN TIME itself.

4. Please note that the Image selected in BulletImageURL is only used if the value of BulletStyle property is set to "CUSTOM

IMAGE" else it is ignored.

5. You can also set the FirstBulletNumber property to set a seed for the Bullet value. The default value is 1 you can now set

it to any number you want your list to begin with.

6. Let us now add a few items to the bulleted list control. So lets go to the Items collection under "MISC". Click on the

ellipsis and a new window should popup showing a list of items to add and remove from the list.

7. CLick on add. A new listitem is added. Set the value of the list item to 100. The Text will automatically pick up the

value set in the "VALUE" property. You should note that this control allows you to enable or disable its list items as one of

the properties in the list is "ENABLED". I think is really good as you the control at a much granular level.

8. Add a few more items to the list and at the end set "SELECTED" property of one OR more items to true.

9. You can iterate through the items to check if the item is selected or not. You should change the Display mode from Text to

Link Button or Hyperlink to select or unselect any item you can put the code for the same in the CLick event as follows

protected void BulletedList1_Click(object sender, BulletedListEventArgs e)
{
Response.Write(e.Index);

for(int i=0;i<BulletedList1.Items.Count ;i++)
{
if(BulletedList1.Items[i].Selected == true)
Response.Write(BulletedList1.Items[i].Value);

BulletedList1.Items[e.Index].Selected = true;

}
}

10. One of the interesting properties of the control is AppendDataBoundItems which allows you to append both static as well

as items from the data source control.

11. Let us create a SQL Server datasource control. You can click DataSourceID and select NewDataSource. In the DataSource

wizard select a SQL DataSource. Connect to the local server and select pubs database. Test your connection. Finally select

the authors table and select columns au_id and au_fnameto be fetched.

12. Let us now set the DataTextField and DataValueField of Bulleted List to au_fname and au_id.

13. Click on F5 and load the page. Please set it to start page before hitting F5. You should be able to view both the statis

items that you had added along with the data from the pubs.authors table.

e.g.

110 --- start static items
120
130
140
150 --- end static items
Abraham --- items from pubs
Reginald
Cheryl
Michel
Innes
Ann
Marjorie
Morningstar
Burt
Sheryl
Livia
Charlene
Stearns
Heather
Michael
Sylvia
Albert
Anne
Meander
Dean
Dirk
Johnson
Akiko

14. You also set the valiation group for the bullet list which will trigger the validation for a set of controls that are a

part of that group when the page is posted back. We must set the CAUSES VALIDATION property to true for the VALIDATIONGROUP

property to be effective. If CAUSES VALIDATION is set to true and VALIDATION PROPERTY is not set then validation is

performed for all the validation controls on the page which are not a member of any validation group.

15. These were a few distinct features of Bulleted List control that we discussed today. There are several other properties

of this control for skins and theming. You can try and explore them.

This is just a beginning to get us started on this control. I will be posting some key features of ASP.NET 2.0 everyday. If

you have any queries please port them or mail them to me at [EMAIL PROTECTED] If you want me to write on anything specific

let me know. I get tooooo many emails hence please send your email with the subject as Query:<watever query in bried> or Suggestion: <appropriate title>.

Thanks a lot for reading this article. Please post your comments and feedback on the group.

Thanks & Regards,
Nasha

View other groups in this category.


Also on MSN:
Start Chatting | Listen to Music | House & Home | Try Online Dating | Daily Horoscopes

To stop getting this e-mail, or change how often it arrives, go to your E-mail Settings.

Need help? If you've forgotten your password, please go to Passport Member Services.
For other questions or feedback, go to our Contact Us page.

If you do not want to receive future e-mail from this MSN group, or if you received this message by mistake, please click the "Remove" link below. On the pre-addressed e-mail message that opens, simply click "Send". Your e-mail address will be deleted from this group's mailing list.
Remove my e-mail address from dotNET User Group Hyd.

Reply via email to