What type of control do you need to retrieve data from the database?
What is the name of the process for allowing a control, such as a
GridView,to extract data from the
retrieved tables and format it properly?
What is a connection string?
What are the four elements of CRUD?
How do you attach a data source to a
If your table has many rows, what should you do in the
GridView to make it easier to read?
What does optimistic concurrency do?
How can you enable users to change the contents of the database from
How can you take an action based on the data in a row, as the table is loaded?
How do you filter the amount of data returned from a SELECT query?
Exercise4-1. We'll start out easy, letting
you create your own
GridView. Create a new
web site called Exercise 4-1. Add to it a
GridView control that shows records from the
Product table with a
Weight greater than 100. The
GridView should list the Product ID, Product Name, Product
Number, Color, and List Price. The user should be able to update and delete
records, sort by rows, and page through the content. Use the Professional
formatting scheme to give it some style. The result should look like Figure 4-27.
Exercise4-2. This one is a little trickier,
but it lets you see how users could interact with the data in a
GridView. Copy the web site from Exercise 4-1 to a
new web site, called Exercise 4-2. Add the ability to select rows in your
GridView. Add two labels and two
read-only textboxes below the
show the selected item's Product Name and color. The result should look like
Exercise4-3. Now it's time to combine what
you've learned from previous chapters with the new stuff, and throw a little
AJAX into the mix as well. Create a new AJAX-enabled web site called Exercise
4-3. This site should have a radio button that gives readers the opportunity to
select whether they want to see data from the Employee table, or the Customer
table. The Employee panel should have a
GridView showing the EmployeeID, ManagerID, and Title. The
Customer panel should have a
the Customer ID, Account Number, and Customer Type. The table that the reader
chooses should appear dynamically in a new panel; the other one should be
invisible. The result should look like Figure 4-29.
Exercise 4-4. Ready for a bit of a challenge? Sure you are. You're going to see how to retrieve data based on multiple customer selections—like you would in a shopping site. Create a new web site called Exercise 4-4. This site should have three dropdown menus:
A Category menu that lists the product categories from the
A Subcategory menu that lists the subcategories of the Category listed
in the first drop-down, by using the
A Color menu that lists the available product colors from the
In addition, there should be a Submit button that users click. Below
all of this is a
displays the Products (from the Product table) that match the chosen
subcategory and color. (You don't need to match the category—all that
control does is dictate the contents of the Subcategory table.) The
GridView should display the
ProductID, Name, Product number, and the color, just so you can tell
it's working. (Hint: You can use the
DISTINCT SQL statement to avoid duplication in your
table.) It should look like Figure 4-30.