Modify the Product Receipt application
In this exercise, youâ€™ll modify a Product Receipt application so it uses an object data
source instead of a SQL data source.
Review the starting code
1. Open the XEx17ProductReceipt application.
2. Review the aspx code for the Default page. Then, run the application to see how it
Build Business Object class and Data Access Class
3. Code the Product class in the Models folder. It defines three properties for the
ProductID, Name, and OnHand columns.
4. Code the ProductDB class. Implement GetProducts method that returns a
List<Product> object and the UpdateProduct method accepts a single Product object
since it doesnâ€™t implement optimistic concurrency.
Add an ObjectDataSource control
5. Add an ObjectDataSource control to the Default page, and configure it so it retrieves
data using the GetProducts method of the ProductDB class and updates a product
using the UpdateProduct method. When youâ€™re done, make sure that the object data
source is configured to use the Product business class to pass values to the update
6. Change the data source for the GridView control from the SQL data source to the
object data source you just created. When a dialog box is displayed asking if you
want to regenerate the GridView column fields and data keys, click No.
7. Delete the SqlDataSource control since itâ€™s no longer used by the page.
8. Run the application and test it to be sure it works correctly.
Use the designer to review the bound fields
9. Display the Fields dialog box for the GridView control. Then, select the ID field, and
scroll through the properties for that field until you can see the DataField property.
10. Display the drop-down list for the DataField property, and notice that you can see the
names of all the available fields. Thatâ€™s because the select method returns a stronglytyped
Please find the attached documents for more details.