drop-down list needs to show current data from (Michigan web site)

drop-down list needs to show current data from the database for example, all users, all items in an Items table, or all users who have made purchases. Whatever you choose from the drop-down list can then be used as a filter for specifying rows to display in a nearby data-bound control. For example, suppose you want to create a page in which you can choose any user in your database and see his or her transactions and profile properties (or whatever) only. Your first move is to create some means of choosing one user. A drop-down list might work nicely for that. To create a drop-down list that shows current database data, follow these steps: 1. Create or open the .aspx page on which you want to place the control. 2. From the Standard category in the Toolbox, drag a DropDownList control onto the page. By default, the control is named DataList1 (assuming it s the first DropDownList control you added to the page). It s important to know the name of the control because to use the control s value for anything useful later, you must refer to it by exactly that name. 3. On the DataList control s Common Tasks menu, select Enable Postback. The above step is important if you intend to use the drop-down list as a means of filtering rows in a table. 4. From the Common Tasks menu, select Choose Data Source. 5. On the wizard page that opens, choose New Data Source. 6. On the first wizard page, choose New Data Source from the drop-down list. 7. Go through the usual steps in the first wizard pages (that is, choose Database, click OK, choose your usual connection string, and click Next). At this point, you re in the Configure SQL Statement page. 8. Choose the table or view that contains the columns you want to show in the drop-down menu. For example, if you want the drop-down menu to show an alphabetical list of all current users, you could choose vw_aspnet_MembershipUsers. 9. Choose the column (or columns) you want to use for the drop-down menu. For example, choose UserName to make the drop-down list show a list of user names. 10. Use the ORDER BY button to sort the items into alphabetical order. When you ve finished, you can click Next (as necessary) and then Finish to work your way back to the control. Chapter 12: Using Data in Web Pages 281
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.

Leave a Reply