<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>ADO.NET team blog : Entity Data Source</title><link>http://blogs.msdn.com/adonet/archive/tags/Entity+Data+Source/default.aspx</link><description>Tags: Entity Data Source</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Tutorial: Entity Data Source Control</title><link>http://blogs.msdn.com/adonet/archive/2008/06/18/tutorial-entity-data-source-control.aspx</link><pubDate>Thu, 19 Jun 2008 00:19:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8618374</guid><dc:creator>dpblogs</dc:creator><slash:comments>12</slash:comments><comments>http://blogs.msdn.com/adonet/comments/8618374.aspx</comments><wfw:commentRss>http://blogs.msdn.com/adonet/commentrss.aspx?PostID=8618374</wfw:commentRss><description>&lt;P&gt;Last month we announced the beta release of Service Pack 1 for Visual Studio 2008. This release includes the Entity Framework, including a wizard that can be used to generate a model and a graphical model designer. It also includes the EntityDataSourceControl, which lets you bind ASP.NET data bound controls to data from a model. 
&lt;P&gt;This tutorial grew out of a project I created during a recent bug-bash of the Entity Framework and the modeling tools. This posting is the first of several in which I will show you how use the Entity Data Model wizard to add an AdventureWorks-based model to a simple Web project. It also shows how to bind data to controls in the web app, both through the EntityDataSource, and by executing queries directly against the entity data model. 
&lt;H5&gt;Prerequisites&lt;/H5&gt;
&lt;UL&gt;
&lt;LI&gt;Visual Studio 2008 
&lt;LI&gt;The beta release of Visual Studio 2008 Service Pack 1 - available for download &lt;A href="http://msdn.microsoft.com/en-us/vstudio/cc533448.aspx" mce_href="http://msdn.microsoft.com/en-us/vstudio/cc533448.aspx"&gt;here&lt;/A&gt;. 
&lt;LI&gt;The AdventureWorks sample DB, which is available in the &lt;A href="http://www.codeplex.com/MSFTDBProdSamples" mce_href="http://www.codeplex.com/MSFTDBProdSamples"&gt;database samples on CodePlex&lt;/A&gt;. I used the version of AdventureWorks that has been updated for SQL Server 2008, but the SQL Server 2005 version should work as well. The AdventureWorksLT database won’t work for the specific tutorial steps as written. &lt;/LI&gt;&lt;/UL&gt;
&lt;H5&gt;Initial Setup&lt;/H5&gt;
&lt;P&gt;These are the steps used to create a simple web project which we will use throughout the tutorial. The steps are written to create a C# based Web project as it’s the .NET language with which I’m most comfortable. 
&lt;OL&gt;
&lt;LI&gt;Open Visual Studio and create an ASP.NET Web Application project named EDMWorks. &lt;BR&gt;a. Click &lt;B&gt;File&lt;/B&gt;, point to &lt;B&gt;New&lt;/B&gt;, and click &lt;B&gt;Project&lt;/B&gt;. &lt;BR&gt;b. Select the &lt;B&gt;ASP.NET Web Application&lt;/B&gt; template and change the project name to &lt;B&gt;EDMWorks&lt;/B&gt;. 
&lt;LI&gt;Rename the Default.aspx page to &lt;B&gt;Products.aspx&lt;/B&gt; 
&lt;LI&gt;Add three web pages to the project named &lt;B&gt;ProductDetails.aspx&lt;/B&gt;, &lt;B&gt;ProductReview.aspx&lt;/B&gt;, and &lt;B&gt;ReadImage.aspx&lt;/B&gt;.&lt;BR&gt;a. In Solution Explorer, right click the project name (&lt;B&gt;EDMWorks&lt;/B&gt;), point to &lt;B&gt;Add&lt;/B&gt;, and click &lt;B&gt;Add New Item&lt;/B&gt;. &lt;BR&gt;b. Select the &lt;B&gt;Web Form&lt;/B&gt; template, and rename it &lt;B&gt;ProductDetails.aspx&lt;/B&gt;. Click &lt;B&gt;Add&lt;/B&gt;. &lt;BR&gt;c. Repeat for the 2 remaining web pages. &lt;/LI&gt;&lt;/OL&gt;
&lt;H5&gt;Use the Designer to add the AdventureWorks model to the Web site&lt;/H5&gt;
&lt;OL&gt;
&lt;LI&gt;Right click the &lt;B&gt;EDMWorks&lt;/B&gt; project and select &lt;B&gt;Add New Item&lt;/B&gt; 
&lt;LI&gt;Select the &lt;B&gt;ADO.NET Entity Data Model&lt;/B&gt; template, and name the model &lt;B&gt;AdventureWorksModel.edmx&lt;/B&gt;. Click &lt;B&gt;Add&lt;/B&gt;. 
&lt;LI&gt;On the &lt;B&gt;Choose Model Contents&lt;/B&gt; page of the wizard, select &lt;B&gt;Generate from database&lt;/B&gt; and click &lt;B&gt;Next&lt;/B&gt;. 
&lt;LI&gt;On the &lt;B&gt;Choose Your Data Connection&lt;/B&gt; page of the wizard, click &lt;B&gt;New Connection&lt;/B&gt; to open the &lt;B&gt;Connection Properties&lt;/B&gt; dialog box to generate a connection string for the AdventureWorks database you want to connect to. 
&lt;LI&gt;In the &lt;B&gt;Save entity connection settings in Web.Config as&lt;/B&gt; text box, enter &lt;B&gt;AdventureWorksModelConnection&lt;/B&gt;, and click &lt;B&gt;Next&lt;/B&gt;. 
&lt;LI&gt;In the &lt;B&gt;Choose Your Database Objects&lt;/B&gt; page of the wizard, select &lt;B&gt;Tables&lt;/B&gt;, &lt;B&gt;Views&lt;/B&gt;, and &lt;B&gt;Stored Procedures&lt;/B&gt;. Use &lt;B&gt;AdventureWorksModel&lt;/B&gt; for the namespace. Click &lt;B&gt;Finish&lt;/B&gt;. &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;We won’t use the actual designer for this tutorial, but you can double-click the AdventureWorksModel.edmx file in Solution Explorer to take a look at the model that was generated by the wizard. 
&lt;H5&gt;Add EntityDataSource controls to the Products.aspx web page&lt;/H5&gt;
&lt;P&gt;This page allows the user to view details about all the products AdventureWorks sells. We will add four data-bound controls and an EntityDataSource control for each as follows:&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE class="" cellSpacing=0 cellPadding=2 width=488 border=1&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top align=middle width=132&gt;&lt;STRONG&gt;Data source name&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top align=middle width=196&gt;&lt;STRONG&gt;Purpose&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top align=middle width=158&gt;&lt;STRONG&gt;Associated data-bound control&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=132&gt;dsCategory&lt;/TD&gt;
&lt;TD class="" vAlign=top width=196&gt;Select the ProductCategory entity’s Name and ProductCategoryID properties. &lt;/TD&gt;
&lt;TD class="" vAlign=top width=158&gt;DropDownList named ddCategory&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=132&gt;dsSubCategory&lt;/TD&gt;
&lt;TD class="" vAlign=top width=196&gt;
&lt;P&gt;Based on the category selected in the Category drop down list, select the ProductSubcategory entity’s Name and ProductSubcategoryID properties.&lt;/P&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=157&gt;GridView named gvwSubcategories&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=132&gt;dsProduct&lt;/TD&gt;
&lt;TD class="" vAlign=top width=196&gt;
&lt;P&gt;Display all the products for the subcategory selected in the Subcategories grid view.&lt;/P&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=157&gt;GridView named gvwProduct&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=132&gt;dsProductDetails&lt;/TD&gt;
&lt;TD class="" vAlign=top width=196&gt;Display details in a DetailsView control about the product that is selected in the Products grid view.&lt;/TD&gt;
&lt;TD class="" vAlign=top width=158&gt;
&lt;P&gt;DetailsView named dvwProduct &lt;BR&gt;Selected fields are Name, Color, and Price&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;H5&gt;Add the dsCategory data source control&lt;/H5&gt;
&lt;OL&gt;
&lt;LI&gt;Open the Products.aspx web page in Design view. 
&lt;LI&gt;Add the four data-bound controls to the page&lt;BR&gt;a. Drag a &lt;B&gt;DropDownList&lt;/B&gt; control from the Toolbox to the designer surface. Rename the control to &lt;B&gt;ddCategory&lt;/B&gt;, and change its &lt;B&gt;AutoPostBack&lt;/B&gt; property to &lt;B&gt;True&lt;/B&gt;.&lt;BR&gt;b. Drag two &lt;B&gt;GridView&lt;/B&gt; controls to the designer surface and rename them &lt;B&gt;gvwSubcategories&lt;/B&gt; and &lt;B&gt;gvwProduct&lt;/B&gt;.&lt;BR&gt;c. Drag a &lt;B&gt;DetailsView&lt;/B&gt; control to the designer surface and rename it &lt;B&gt;dvwProduct&lt;/B&gt;. 
&lt;LI&gt;Build the project. This is needed to generate the metadata for the model before we can connect the EntityDataSource control to it. 
&lt;LI&gt;Drag an &lt;B&gt;EntityDataSource&lt;/B&gt; control from the Toolbox to the designer surface, next to the &lt;B&gt;ddCategory&lt;/B&gt; drop down list.&lt;BR&gt;&lt;BR&gt;NOTE: if the EntityDataSource control is not available in the Data section of your Toolbox, Guy Burstein's blog post on the EntityDataSource control tells how to add it:&lt;BR&gt;&lt;BR&gt;&lt;A href="http://blogs.microsoft.co.il/blogs/bursteg/archive/2008/05/12/EntityDataSource-Entity-Data-Source.aspx" mce_href="http://blogs.microsoft.co.il/blogs/bursteg/archive/2008/05/12/EntityDataSource-Entity-Data-Source.aspx"&gt;http://blogs.microsoft.co.il/blogs/bursteg/archive/2008/05/12/EntityDataSource-Entity-Data-Source.aspx&lt;/A&gt;&lt;BR&gt;
&lt;LI&gt;Under the &lt;B&gt;EntityDataSource Tasks&lt;/B&gt; flyout, click &lt;B&gt;Configure Data Source&lt;/B&gt;&lt;A href="http://blogs.msdn.com/blogfiles/adonet/WindowsLiveWriter/ae70e649a59f_996F/edscTutorial_1_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/adonet/WindowsLiveWriter/ae70e649a59f_996F/edscTutorial_1_2.jpg"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=76 alt=edscTutorial_1 src="http://blogs.msdn.com/blogfiles/adonet/WindowsLiveWriter/ae70e649a59f_996F/edscTutorial_1_thumb.jpg" width=311 border=0 mce_src="http://blogs.msdn.com/blogfiles/adonet/WindowsLiveWriter/ae70e649a59f_996F/edscTutorial_1_thumb.jpg"&gt;&lt;/A&gt; &lt;BR&gt;The Configure Data Source wizard launches&lt;BR&gt;
&lt;LI&gt;On the &lt;B&gt;Configure Object Context&lt;/B&gt; page of the wizard, select &lt;B&gt;AdventureWorksModelConnection&lt;/B&gt; in both the &lt;B&gt;Named Connection&lt;/B&gt; and the &lt;B&gt;DefaultContainerName&lt;/B&gt; drop down lists. Click &lt;B&gt;Next&lt;/B&gt;. 
&lt;LI&gt;On the &lt;B&gt;Configure Data Selection&lt;/B&gt; page of the wizard, in the &lt;B&gt;EntitySetName&lt;/B&gt; drop down list, select &lt;B&gt;ProductCategory&lt;/B&gt;. In the &lt;B&gt;Select&lt;/B&gt; list box, check &lt;B&gt;ProductCategoryID&lt;/B&gt; and &lt;B&gt;Name&lt;/B&gt;. Click &lt;B&gt;Finish&lt;/B&gt;.&lt;BR&gt;&lt;BR&gt;This configures the selection for the data source, but we also want to add an OrderBy clause to ensure the returned list of categories is ordered by the category’s name, and not its Id.&lt;BR&gt;
&lt;LI&gt;In the Properties window for the data source control, click the field next to &lt;B&gt;OrderBy&lt;/B&gt; and click the ellipsis button&lt;A href="http://blogs.msdn.com/blogfiles/adonet/WindowsLiveWriter/ae70e649a59f_996F/edscTutorial_2_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/adonet/WindowsLiveWriter/ae70e649a59f_996F/edscTutorial_2_2.jpg"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=84 alt=edscTutorial_2 src="http://blogs.msdn.com/blogfiles/adonet/WindowsLiveWriter/ae70e649a59f_996F/edscTutorial_2_thumb.jpg" width=233 border=0 mce_src="http://blogs.msdn.com/blogfiles/adonet/WindowsLiveWriter/ae70e649a59f_996F/edscTutorial_2_thumb.jpg"&gt;&lt;/A&gt; &lt;BR&gt;This opens the Expression Editor for the data source control.&lt;BR&gt;
&lt;LI&gt;In the &lt;B&gt;OrderBy Expression&lt;/B&gt; text box, enter &lt;B&gt;it.Name&lt;/B&gt;. Click &lt;B&gt;OK&lt;/B&gt;. 
&lt;LI&gt;Rename the control to &lt;B&gt;dsCategory.&lt;/B&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;H5&gt;Bind the dsCategory data source control to the ddCategory drop down list&lt;/H5&gt;
&lt;OL&gt;
&lt;LI&gt;Click the flyout for the &lt;B&gt;ddCategory&lt;/B&gt; drop down list, and under &lt;B&gt;DropDownList Tasks&lt;/B&gt;, select &lt;B&gt;Choose Data Source&lt;BR&gt;&lt;BR&gt;&lt;/B&gt;The Data Source Configuration Wizard launches&lt;BR&gt;
&lt;LI&gt;On the &lt;B&gt;Choose a Data Source&lt;/B&gt; page of the wizard, select &lt;B&gt;dsCategory&lt;/B&gt; in the &lt;B&gt;Select a data source&lt;/B&gt; drop down list. 
&lt;LI&gt;Configure the control to display the &lt;B&gt;Name&lt;/B&gt; property in the drop down list, and to use the &lt;B&gt;ProductCategoryID&lt;/B&gt; for the list’s value:&lt;A href="http://blogs.msdn.com/blogfiles/adonet/WindowsLiveWriter/ae70e649a59f_996F/edscTutorial_3_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/adonet/WindowsLiveWriter/ae70e649a59f_996F/edscTutorial_3_2.jpg"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=157 alt=edscTutorial_3 src="http://blogs.msdn.com/blogfiles/adonet/WindowsLiveWriter/ae70e649a59f_996F/edscTutorial_3_thumb.jpg" width=244 border=0 mce_src="http://blogs.msdn.com/blogfiles/adonet/WindowsLiveWriter/ae70e649a59f_996F/edscTutorial_3_thumb.jpg"&gt;&lt;/A&gt; 
&lt;LI&gt;Click &lt;B&gt;OK&lt;/B&gt; to finish binding the data source to the control. 
&lt;P&gt;At this point you can run the Web project to verify that the control is correctly picking up the product categories from the AdventureWorks database:&lt;BR&gt;&lt;A href="http://blogs.msdn.com/blogfiles/adonet/WindowsLiveWriter/ae70e649a59f_996F/edscTutorial_4_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/adonet/WindowsLiveWriter/ae70e649a59f_996F/edscTutorial_4_2.jpg"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=122 alt=edscTutorial_4 src="http://blogs.msdn.com/blogfiles/adonet/WindowsLiveWriter/ae70e649a59f_996F/edscTutorial_4_thumb.jpg" width=140 border=0 mce_src="http://blogs.msdn.com/blogfiles/adonet/WindowsLiveWriter/ae70e649a59f_996F/edscTutorial_4_thumb.jpg"&gt;&lt;/A&gt;&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;H5&gt;Add the dsSubCategory data source control&lt;/H5&gt;
&lt;OL&gt;
&lt;P&gt;This control is hooked to a grid view, and is used to display a product subcategory based on the selection in the ddCategory drop down list. 
&lt;LI&gt;Drag an &lt;B&gt;EntityDataSource&lt;/B&gt; control from the Toolbox to the designer surface. Name the control &lt;B&gt;dsSubCategory&lt;/B&gt;. 
&lt;LI&gt;Under the &lt;B&gt;EntityDataSource Tasks&lt;/B&gt; flyout, click &lt;B&gt;Configure Data Source&lt;/B&gt;. Use the Configure Data Source wizard to select the &lt;B&gt;ProductSubcategory&lt;/B&gt; entity’s &lt;B&gt;ProductSubcategoryID&lt;/B&gt; and &lt;B&gt;Name&lt;/B&gt; properties.&lt;BR&gt;&lt;BR&gt;For this data source, we need to add a Where clause to filter the selection based on the ProductCategory that was selected in the ddCategory drop down list. &lt;BR&gt;&lt;BR&gt;NOTE: In the beta release of the service pack, you can’t use the expression editor to generate a parameterized clause that is bound to a control’s value. Because of this, we’ll create the Where clause in the .aspx file.&lt;BR&gt;
&lt;LI&gt;Switch to Source view to edit the Products.aspx file. 
&lt;LI&gt;Find the code for the &lt;B&gt;dsSubCategory&lt;/B&gt; control, and add a &lt;B&gt;Where&lt;/B&gt; clause and &lt;B&gt;WhereParamaters&lt;/B&gt;, so it looks like the following:&lt;BR&gt;&lt;BR&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;EntityDataSource &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;ID&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="dsSubCategory"&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;runat&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;="server" &lt;BR&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;ConnectionString&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;="name=AdventureWorksModelConnection" &lt;BR&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;DefaultContainerName&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;="AdventureWorksModelConnection" &lt;BR&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;EntitySetName&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;="ProductSubcategory" &lt;BR&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Select&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="it.[ProductSubcategoryID], it.[Name]"&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Where&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;="it.ProductCategory.ProductCategoryID = @ProductCategoryID"&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;WhereParameters&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ControlParameter &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;ControlID&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;="ddCategories" &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Type&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Int32"&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;="ProductCategoryID" /&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;WhereParameters&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;BR&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;EntityDataSource&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;SPAN style="COLOR: blue"&gt;&lt;/SPAN&gt;
&lt;H5&gt;Bind the dsSubCategory data source control to the Subcategories grid view&lt;/H5&gt;
&lt;OL&gt;
&lt;LI&gt;Switch back to the Design view of Products.aspx. 
&lt;LI&gt;Click the flyout for the &lt;B&gt;gvwSubcategories&lt;/B&gt; grid view to open the &lt;B&gt;GridView Tasks&lt;/B&gt;. 
&lt;LI&gt;In the &lt;B&gt;GridView Tasks&lt;/B&gt;, select the &lt;B&gt;Enable Selection&lt;/B&gt; option. 
&lt;LI&gt;Select &lt;B&gt;dsSubCategory&lt;/B&gt; in the &lt;B&gt;Choose Data Source&lt;/B&gt; list. 
&lt;LI&gt;Click &lt;B&gt;Edit Columns&lt;/B&gt; to open the &lt;B&gt;Fields&lt;/B&gt; dialog box. 
&lt;LI&gt;Clear the check box for the &lt;B&gt;Auto-generate fields&lt;/B&gt; option. 
&lt;LI&gt;Click the &lt;B&gt;Refresh Schema&lt;/B&gt; link. This updates the available fields with the bound fields &lt;B&gt;ProductSubcategoryID&lt;/B&gt; and &lt;B&gt;Name&lt;/B&gt; from the data source. 
&lt;LI&gt;Select the &lt;B&gt;Name&lt;/B&gt; bound field from the &lt;B&gt;Avaliable fields&lt;/B&gt; list, and click &lt;B&gt;Add&lt;/B&gt;. This adds the &lt;B&gt;Name&lt;/B&gt; field to the &lt;B&gt;Selected fields&lt;/B&gt; list. 
&lt;LI&gt;In the &lt;B&gt;BoundField&lt;/B&gt; properties, change the &lt;B&gt;HeaderText&lt;/B&gt; property from &lt;B&gt;Name&lt;/B&gt; to &lt;B&gt;Subcategories&lt;/B&gt;. 
&lt;LI&gt;In the &lt;B&gt;Selected fields&lt;/B&gt; list, click the &lt;B&gt;Select&lt;/B&gt; command. Click the button with the blue down arrow to move the &lt;B&gt;Select&lt;/B&gt; field to the bottom of the list. 
&lt;LI&gt;In the &lt;B&gt;CommandField&lt;/B&gt; properties, change the value for the &lt;B&gt;SelectText&lt;/B&gt; property to &lt;B&gt;[&amp;gt;]&lt;/B&gt;. 
&lt;LI&gt;Switch to the Source view , and set the DataKeyNames for the control to ProductSubcategoryID as follows:&lt;/LI&gt;&lt;/OL&gt;
&lt;BLOCKQUOTE&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;GridView &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;ID&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="gvwSubcategories" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;runat&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="server" 
&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;AutoGenerateColumns&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="False" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;DataSourceID&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="dsSubCategory" 
      &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;DataKeyNames&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="ProductSubcategoryID"&amp;gt;
&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;FONT color=#000000&gt;&lt;/FONT&gt;
&lt;P&gt;At this point you can run the Web site to verify that the grid view displays the subcategories &lt;BR&gt;based on the selected category:&lt;BR&gt;&lt;A href="http://blogs.msdn.com/blogfiles/adonet/WindowsLiveWriter/ae70e649a59f_996F/edscTutorial_5_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/adonet/WindowsLiveWriter/ae70e649a59f_996F/edscTutorial_5_2.jpg"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=146 alt=edscTutorial_5 src="http://blogs.msdn.com/blogfiles/adonet/WindowsLiveWriter/ae70e649a59f_996F/edscTutorial_5_thumb.jpg" width=149 border=0 mce_src="http://blogs.msdn.com/blogfiles/adonet/WindowsLiveWriter/ae70e649a59f_996F/edscTutorial_5_thumb.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;H5&gt;Add the dsProduct data source control&lt;/H5&gt;
&lt;P&gt;This control is hooked to a grid view, and is used to display all products for a given subcategory, based on the selection in the Subcategories grid view 
&lt;OL&gt;
&lt;LI&gt;Drag an &lt;B&gt;EntityDataSource&lt;/B&gt; control from the Toolbox to the designer surface and name it &lt;B&gt;dsProduct&lt;/B&gt;. 
&lt;LI&gt;Use similar steps to those you took to create the &lt;B&gt;dsSubcategory&lt;/B&gt; data source, except this time the you want to select the &lt;B&gt;Product&lt;/B&gt; entity’s &lt;B&gt;ProductID&lt;/B&gt; and &lt;B&gt;Name&lt;/B&gt; properties, and your &lt;B&gt;Where&lt;/B&gt; clause should select the &lt;B&gt;Products&lt;/B&gt; whose &lt;B&gt;SubcategoryID&lt;/B&gt; matches the selection in the &lt;B&gt;Subcategories&lt;/B&gt; grid view. &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;The finished markup code should look something like: 
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;EntityDataSource &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;ID&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="dsProduct"&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;runat&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;="server" &lt;BR&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;ConnectionString&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;="name=AdventureWorksModelConnection"&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;DefaultContainerName&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;="AdventureWorksModelConnection"&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;EntitySetName&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;="Product"&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Select&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="it.[ProductID], it.[Name]"&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;OrderBy&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;="it.[Name]"&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Where&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;="it.ProductSubcategory.ProductSubcategoryID =&lt;BR&gt;@ProductSubcategoryID"&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;WhereParameters&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ControlParameter &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;ControlID&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;="gvwSubcategories"&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;="ProductSubcategoryID"&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;PropertyName&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="SelectedValue"&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Type&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;="Int32"/&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;WhereParameters&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;BR&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;EntityDataSource&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;&lt;FONT face="Courier New"&gt;&amp;gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN style="COLOR: blue"&gt;&lt;/BLOCKQUOTE&gt;&lt;/SPAN&gt;
&lt;P&gt;&lt;FONT color=#000000&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;H5&gt;&lt;FONT color=#000000&gt;Bind the dsProduct data source control to the gvwProduct grid view&lt;/FONT&gt;&lt;/H5&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;FONT color=#000000&gt;Click the flyout for the &lt;B&gt;gvwProduct&lt;/B&gt; grid view to open the &lt;B&gt;GridViewTasks&lt;/B&gt;.&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT color=#000000&gt;In the &lt;B&gt;GridView Tasks&lt;/B&gt;, select the &lt;B&gt;Enable Paging&lt;/B&gt; and &lt;B&gt;Enable Selection&lt;/B&gt; options.&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT color=#000000&gt;In the &lt;B&gt;Choose Data Source&lt;/B&gt; list, select &lt;B&gt;dsProduct&lt;/B&gt;.&lt;/FONT&gt;&amp;nbsp; 
&lt;LI&gt;&lt;FONT color=#000000&gt;Click &lt;B&gt;Edit Columns&lt;/B&gt; to open the &lt;B&gt;Fields&lt;/B&gt; dialog box.&lt;/FONT&gt;&amp;nbsp; 
&lt;LI&gt;&lt;FONT color=#000000&gt;Clear the check box for the &lt;B&gt;Auto-generate fields&lt;/B&gt; option.&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT color=#000000&gt;Click the &lt;B&gt;Refresh Schema&lt;/B&gt; link. This updates the available fields with the bound fields &lt;B&gt;ProductID&lt;/B&gt; and &lt;B&gt;Name&lt;/B&gt; from the data source.&lt;/FONT&gt;&amp;nbsp; 
&lt;LI&gt;&lt;FONT color=#000000&gt;Select the &lt;B&gt;Name&lt;/B&gt; bound field from the &lt;B&gt;Avaliable fields&lt;/B&gt; list, and click &lt;B&gt;Add&lt;/B&gt;. This adds the &lt;B&gt;Name&lt;/B&gt; field to the &lt;B&gt;Selected fields&lt;/B&gt; list.&lt;/FONT&gt;&amp;nbsp; 
&lt;LI&gt;&lt;FONT color=#000000&gt;In the &lt;B&gt;BoundField&lt;/B&gt; properties, change the &lt;B&gt;HeaderText&lt;/B&gt; property from &lt;B&gt;Name&lt;/B&gt; to &lt;B&gt;Products&lt;/B&gt;. &lt;/FONT&gt;
&lt;LI&gt;&lt;FONT color=#000000&gt;In the &lt;B&gt;Selected fields&lt;/B&gt; list, click the &lt;B&gt;Select&lt;/B&gt; command. Click the button with the blue down arrow to move the Select field to the bottom of the list.&lt;/FONT&gt;&amp;nbsp; 
&lt;LI&gt;&lt;FONT color=#000000&gt;In the &lt;B&gt;CommandField&lt;/B&gt; properties, change the value for the &lt;B&gt;SelectText&lt;/B&gt; property to &lt;B&gt;[&amp;gt;]&lt;/B&gt;. Click &lt;B&gt;OK&lt;/B&gt;.&lt;/FONT&gt;&amp;nbsp; 
&lt;LI&gt;&lt;FONT color=#000000&gt;Switch to the Source view , and set the &lt;B&gt;DataKeyNames&lt;/B&gt; for the control to &lt;B&gt;ProductID&lt;/B&gt; as follows:&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;BLOCKQUOTE&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;GridView &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;ID&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="gvwProduct" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;runat&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="server" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;AllowPaging&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="True" 
&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;AutoGenerateColumns&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="False" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;DataSourceID&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="dsProduct" 
&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;DataKeyNames&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="ProductID"&amp;gt;
&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;&lt;/SPAN&gt;
&lt;P&gt;At this point you can run the Web site to verify that the grid view displays the products based &lt;BR&gt;on the selected subcategory: 
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/adonet/WindowsLiveWriter/ae70e649a59f_996F/edscTutorial_6_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/adonet/WindowsLiveWriter/ae70e649a59f_996F/edscTutorial_6_2.jpg"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=244 alt=edscTutorial_6 src="http://blogs.msdn.com/blogfiles/adonet/WindowsLiveWriter/ae70e649a59f_996F/edscTutorial_6_thumb.jpg" width=107 border=0 mce_src="http://blogs.msdn.com/blogfiles/adonet/WindowsLiveWriter/ae70e649a59f_996F/edscTutorial_6_thumb.jpg"&gt;&lt;/A&gt; 
&lt;H5&gt;Add the dsProductDetails data source control&lt;/H5&gt;
&lt;P&gt;This control is hooked to a details view, and is used to display information about the product selected in the Products grid view. 
&lt;OL&gt;
&lt;LI&gt;Drag an &lt;B&gt;EntityDataSource&lt;/B&gt; control from the Toolbox to the designer surface, and name it &lt;B&gt;dsProductDetails&lt;/B&gt;. 
&lt;LI&gt;Use similar steps to those you took to create the previous data sources, except this time you want to select the &lt;B&gt;Product&lt;/B&gt; entity’s &lt;B&gt;ProductID&lt;/B&gt;, &lt;B&gt;Name&lt;/B&gt;, &lt;B&gt;Color&lt;/B&gt;, and &lt;B&gt;ListPrice&lt;/B&gt; properties, and your &lt;B&gt;Where&lt;/B&gt; clause should select the &lt;B&gt;Product&lt;/B&gt; whose &lt;B&gt;ProductID&lt;/B&gt; matches the selection in the &lt;B&gt;gvwProducts&lt;/B&gt; grid view. &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;The finished markup code should look something like: 
&lt;BLOCKQUOTE&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;EntityDataSource &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;ID&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="dsProductDetails" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;runat&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="server" 
&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;ConnectionString&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="name=AdventureWorksModelConnection" 
&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;DefaultContainerName&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="AdventureWorksModelConnection"
&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;EntitySetName&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Product" 
&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Select&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="it.[ProductID], it.[Name], it.[Color], it.[ListPrice]" 
      &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Where&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="it.ProductID = @ProductID"&amp;gt;
      &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;WhereParameters&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
          &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ControlParameter &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;ControlID&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="gvwProduct" 
&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="ProductID" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;PropertyName&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="SelectedValue"
&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Type&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Int32" /&amp;gt;
      &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;WhereParameters&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;EntityDataSource&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;
&lt;H5&gt;Bind the dsProductDetails data source control to the dvwProduct details view&lt;/H5&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;FONT color=#000000&gt;Click the flyout for the &lt;B&gt;dvwProduct&lt;/B&gt; details view to open the &lt;B&gt;DetailsViewTasks&lt;/B&gt;.&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT color=#000000&gt;Select &lt;B&gt;dsProductDetails&lt;/B&gt; in &lt;B&gt;the Choose Data Source&lt;/B&gt; list.&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT color=#000000&gt;Click &lt;B&gt;Edit Fields&lt;/B&gt; to open the &lt;B&gt;Fields&lt;/B&gt; dialog box.&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT color=#000000&gt;Clear the check box for the &lt;B&gt;Auto-generate fields&lt;/B&gt; option.&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT color=#000000&gt;Click the &lt;B&gt;Refresh Schema&lt;/B&gt; link. This updates the available fields with the bound fields &lt;B&gt;ProductID&lt;/B&gt;, &lt;B&gt;Name&lt;/B&gt;, &lt;B&gt;Color&lt;/B&gt;, and &lt;B&gt;ListPrice&lt;/B&gt; from the data source.&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT color=#000000&gt;Add the &lt;B&gt;Name&lt;/B&gt;, &lt;B&gt;Color&lt;/B&gt;, and &lt;B&gt;ListPrice&lt;/B&gt; fields to the selected fields. Change the &lt;B&gt;HeaderText&lt;/B&gt; properties for the &lt;B&gt;Name&lt;/B&gt; and &lt;B&gt;ListPrice&lt;/B&gt; fields to &lt;B&gt;Product&lt;/B&gt; and &lt;B&gt;Price&lt;/B&gt;, respectively. &lt;/FONT&gt;
&lt;LI&gt;&lt;FONT color=#000000&gt;Select &lt;B&gt;TemplateField&lt;/B&gt; in the available fields list, and click &lt;B&gt;Add&lt;/B&gt; twice to add two template fields to the selected fields.&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT color=#000000&gt;Click &lt;B&gt;OK&lt;/B&gt; to close the &lt;B&gt;Fields&lt;/B&gt; dialog box.&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt;You can use the &lt;B&gt;ItemTemplate&lt;/B&gt; editor, but I find it easier to edit templates directly in the source code&lt;BR&gt;&lt;/FONT&gt;
&lt;LI&gt;&lt;FONT color=#000000&gt;Switch to the Source view to edit the two item templates you just added. Edit the code for your details view so the TemplateFields look like the following:&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;BLOCKQUOTE&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;TemplateField&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ItemTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;a &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;href&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;='ProductDetails.aspx?ProductID=&amp;lt;%# Eval("ProductID") %&amp;gt;'&amp;gt;
             [More Details...]&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;a&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
        &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ItemTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
    &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;TemplateField&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;TemplateField&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ItemTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;a &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;href&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;='ProductReview.aspx?ProductID=&amp;lt;%# Eval("ProductID") %&amp;gt;&lt;BR&gt;&amp;amp;ProductName=&amp;lt;%# Eval("Name") %&amp;gt;'&amp;gt;
[Product Reviews...]&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;a&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
    &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ItemTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;asp&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;TemplateField&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;
&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;&lt;FONT color=#000000&gt;At this point you can run the Web site to verify that the details view displays the Name, Color, and Price for the correct product:&lt;/FONT&gt;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/adonet/WindowsLiveWriter/ae70e649a59f_996F/edscTutorial_7_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/adonet/WindowsLiveWriter/ae70e649a59f_996F/edscTutorial_7_2.jpg"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=361 alt=edscTutorial_7 src="http://blogs.msdn.com/blogfiles/adonet/WindowsLiveWriter/ae70e649a59f_996F/edscTutorial_7_thumb.jpg" width=120 border=0 mce_src="http://blogs.msdn.com/blogfiles/adonet/WindowsLiveWriter/ae70e649a59f_996F/edscTutorial_7_thumb.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;That’s it for the first post in this tutorial. In later postings, I’ll show how to implement the code for the ProductDetails and ProductReview pages. I’ll also show how to read the images for the selected products using Entity SQL queries executed against the model. 
&lt;P&gt;Additional Links: 
&lt;P&gt;Guy Burstein has created a &lt;A href="http://channel9.msdn.com/ShowPost.aspx?PostID=403764" mce_href="http://channel9.msdn.com/ShowPost.aspx?PostID=403764"&gt;screencast about the EntityDataSource control&lt;/A&gt; on Channel 9. 
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Eric Dettinger&lt;BR&gt;Software Design Engineer in Test, ADO.NET Entity Framework&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8618374" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/adonet/archive/tags/ADO.NET/default.aspx">ADO.NET</category><category domain="http://blogs.msdn.com/adonet/archive/tags/Entity+Framework/default.aspx">Entity Framework</category><category domain="http://blogs.msdn.com/adonet/archive/tags/Entity+Data+Source/default.aspx">Entity Data Source</category><category domain="http://blogs.msdn.com/adonet/archive/tags/ASP.NET/default.aspx">ASP.NET</category></item></channel></rss>