ASP.NET v2.0: Introducing BulletedList Control
page 4 of 5
by Colt Kwong
Feedback
Average Rating: 
Views (Total / Last 10 Days): 34688/ 66

DataBinding to BulletedList Control

DataBinding to BulletedList Control

 

DataBinding to a BulletedList Control is extremely simple in ASP.NET v2.0, you can drag such control and drop it onto the desiger pane, and then a "Wizard" will guide you throughout the process.

 

After clicking on the "Connect To DataSource..." button, you can select an existing DataSource or create a a new data source control as:

  • SqlDataSource,
  • AccessDataSource,
  • DataSetDataSource,
  • ObjectDataSource,
  • SiteMapDataSource
  • XmlDataSource

You are now able to create a XXXDataSource control easily

(You can of course customize the edit command and parameter, with the help of Query Editor when creating the XXXDataSource control.

 

If you want to know more about the SqlDataSource Control, you can take a look at my previous article:
Data Access Control - SqlDataSourceControl on ASPAlliance)

Imagine that there's a table named "Category", which have two Columns of "CategoryID" and "Category" in a SQL Server, and finally the code generated by Visual Studio "Whidbey" will look like:

 

<asp:bulletedlist bulletstyle="Disc" displaymode="Text" id="Bulletedlist1" runat="server" datatextfield="Category" datasourceid="SqlDataSource1" datavaluefield="CategoryID" />

 

<asp:sqldatasource id="SqlDataSource1" runat="server" selectcommand="SELECT Category.* FROM Category"     providername="System.Data.OleDb" connectionstring="UpdateConnectionStringHereToUseSecureStorage"

/>

No databinding, No data access code, No dynamic control, No Repeater control, No custom control.... what I write (actually I drag & drop with a couple of click) is just the 2 declaration above and then the result become:

 

 

 

 

* The ProviderName of the SqlDataSourceControl above show "System.Data.OleDb" because I'm using the Alpha bit when writing this article, and SQL provider will be implemented by Beta


View Entire Article

User Comments

Title: Direct Post   
Name: Icer
Date: 2007-03-20 5:17:40 AM
Comment:
It is pretty easy to redirect to another page: (The display style has to be "Hyperlink")

ListItem item = new ListItem(Title, Url);
BulletedList.Items.Add(item);

That´s it.
Title: Controlling URL in Hyperlink mode   
Name: Patrick Farrell
Date: 2007-02-26 12:36:37 PM
Comment:
In response to Russ's comments. Although it's not necessarily intuitive, when you are using the BulletedList and you have the display mode set to URL, ListItem.Value renders the link url, ListItem.Text renders the display.

http://patf.net/blogs
Title: Images do not exist   
Name: Ozma
Date: 2006-03-22 2:18:56 PM
Comment:
The images in this article are no longer at the URLs used in the markup
Title: Still Can't Post Directly to Another Page   
Name: Russ Brooks
Date: 2006-03-19 3:08:08 PM
Comment:
The control is essentially useless because we still can not post driectly to another page. Like most .NET controls, why isn't there an "Url" attribute and a way to append a query string? True we can use the onclick, capture the event in the code-behind, then redirect with an appended query string, but why cause two requests on the server and skew logging and traffic metrics? Even 5 years after the advent of .NET, Microsoft still thinks a website can be built with a single page.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2022 ASPAlliance.com  |  Page Processed at 2022-10-06 3:11:03 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search