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