12.2. Data Source and Data-Bound Controls Working Together

The SqlDataSource control allows you to quickly create functional, database-driven web pages. Without writing a whole lot of code, you can create web pages that allow you to perform all four operations of the CRUD acronym: create, read, update, and delete data. Although its name may seem to imply that the control can only access Microsoft's SQL Server, that's not the case. The control can access other databases, such as Oracle or MySQL as well.

12.2.1. Displaying and Editing Data with GridView

To give you an idea of how the SqlDataSource control works in conjunction with the data-bound controls, the next Try It Out lets you create a very simple data-driven web page that allows you to manage the records that are stored in the Genre table in the database. This chapter assumes you have the PlanetWrox.mdf database with the Genre and Review tables in your App_Data folder. It's also assumed that these tables each contain at least a few records. If you didn't follow the steps in the previous chapter, or you're not sure you followed them correctly, be sure to grab a copy of the files PlanetWrox.mdf and PlanetWrox_log.ldf from the Resources folder in the code download for this chapter (at C:\BegASPNET\Resources\Chapter 12) and drop them in the App_Data folder of the Planet Wrox web site, overwriting the existing database if you had one. It's also a good idea to get a copy of the PlanetWrox.mdf database from the Resources folder ...

Get Beginning ASP.NET 3.5: In C# and VB now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.