As with ASP.Net 1.1, v2.0 List style server controls still share common properties, methods and events, but now they share even more. Because of the declarative style of design which is now implemented, they can also use the DataSource control to populate the lists instead of using code. Also, there is another List control presented here, the Bulleted List (like an HTML Select List). It’s functionality is much more than what is presented here, but this gives you a basic ‘first look’.
As you will see, they are sharing one DataSourceID for population data population. For this sample, the Northwind database is used, with a SQLDataSource control, and the Categories table is used.
<html> <head> <meta name="GENERATOR" Content="ASP Express 5.0"> <title>List Style Server Controls</title> </head> <body> <form id="form1" Runat="server"> <table width="100%" cellpadding="0" cellspacing="0" border="0" bgcolor=#6397F8> <tr bgcolor="#BCD2FC"> <td align="left" style="color:#000000"" valign="top"> <asp:RadioButtonList ID="rbl" Runat="Server" DataTextField="CategoryName" DataValuefield="CategoryID" DataSourceID="ds1" /> </td> <td align="left" style="color:#000000"" valign="top"> <asp:CheckBoxList id="cbl" Runat="server" DataTextField="CategoryName" DataValuefield="CategoryID" DataSourceID="ds1" /> </td> <td align="left" style="color:#000000"" valign="top"> <asp:ListBox id="lb" Runat="server" DataTextField="CategoryName" DataValuefield="CategoryID" DataSourceID="ds1" /> </td> <td align="left" style="color:#000000"" valign="top"> <asp:DropDownList id="PutIDNameHere" Runat="server" DataTextField="CategoryName" DataValuefield="CategoryID" DataSourceID="ds1" /> </td> <td align="left" style="color:#000000"" valign="top"> <asp:BulletedList ID="BulletedList1" runat="server" DataTextField="CategoryName" DataValuefield="CategoryID" BulletStyle="Disc" DataSourceID="ds1" /> </td> <td align="left" style="color:#000000"" valign="top"> <asp:BulletedList ID="BulletedList2" runat="server" DataTextField="CategoryName" DataValuefield="CategoryID" BulletStyle="Numbered" DataSourceID="ds1" /> </td> </tr> </table> <asp:SQLDataSource ID="ds1" Runat="Server" SelectCommand = "SELECT CategoryID, CategoryName From Categories" ConnectionString="YourConnectionStringGoesHere"> </asp:SQLDataSource> </form> </body> </html>