Configuring the Object Data Source
You will now add an ObjectDataSource control to your project and configure it to
use the data access class
you just created.
1. Click the Authors.aspx tab and ensure that you are in
Design view. From the Toolbox, in the Data
section, drag an ObjectDataSource onto the design surface,
placing it next to the existing SqlDataSource control.

2. In the ObjectDataSource Tasks menu click Configure
Data Source. In the Configure Data Source wizard,
uncheck Show only data components. For Choose your business object select
DataAccess and then click Next.
3. In Define Data Methods, for Choose a method
select GetAuthors, and then click Next.
The Define Parameters step should look familiar. This
is where you tell the data source to use the selected stateDropDownList
value as a parameter in the SELECT statement.
4. For Parameter source
select Control. For ControlID select stateDropDownList,
and for DefaultValue enter "CA". Then click Finish.
5. Finally, give the ObjectDataSource control a more meaningful
ID. In the Properties window change the (ID)
property to "authorsObjectDataSource". Press CTRL+S to save your
work.
Your object data source is now configured and ready for consumption by the GridView control.
Powered By ASP.NET v2.0
|