Data to Web in Five Minutes with Visual Web Developer 2005, Page 2
VWD offers you quite a bit of flexibility in both getting the data to the Web page and in the way that you display it. On the presentation side, the Data tab of the toolbox includes five different controls:
- GridView, which you've already see (this control replaces the DataGrid from earlier versions of Visual Studio .NET).
- DataList, which drops all of the records on the page in one long list.
- DetailsView, which provides a tabular, pageable view of the data.
- FormView, shown in Figure 3, which also gives you a view oriented towards one record at a time.
- Repeater, which lets you create your own templates to display the data any way that you'd like.
The toolbox also contains multiple controls to let you grab different types of data and make them available to Web pages:
- SqlDataSource, for SQL Server data.
- AccessDataSource, for Microsoft Access data.
- ObjectDataSource, which can use a business object as the source of data.
- DataSetDataSource, for data that's already been pulled into a DataSet.
- XmlDataSource, for data in XML files.
- SiteMapDataSource, which is specialized for building navigation controls.
To investigate further, I suggest you dig into the ObjectDataSource. Many Web developers consider it poor form to link the data directly to the Web pages that present it in any but the smallest and most trivial of applications. What the ObjectDataSource lets you do is configure your Web page to draw its data from business objects, so you get a true data layer in between the database and the application. In this beta, you still have to write a fair amount of code to build those business objects, so I can't get them done in the five minutes allotted. Perhaps in the final release, Microsoft will manage to get all of the plumbing in place for an even more compelling release!
Meanwhile, this first beta is pretty darned amazing. Remember, though, that it is beta software. Don't put it on a machine that you can't afford to seriously damage, and don't try to use it for anything that you plan to actually release. Testing with VMware or Virtual PC is the ideal way to go if you don't have a spare computer hanging around for the testing. Have fun!
Mike Gunderloy is the author of over 20 books and numerous articles on development topics, and the lead developer for Larkware. Check out his latest book, Coder to Developer from Sybex. When he's not writing code, Mike putters in the garden on his farm in eastern Washington state.