Now that you have and entity data model you can create a web
form that will use this model.
1.
Right click on the web site in the Solution Explorer and select Add New
Item… from the pop-up menu.
2.
Select Web Form from the list of templates and leave the name of the
file set to Default.aspx. click the Add button
3.
The Default.aspx web form will be added to your project and the markup
is displayed. Switch your view to Design mode.
4.
Expand the Data node in your toolbox and you should see the
EntityDataSource control. Drag this control onto your web form. You can drop
it anywhere on the form.
5.
Click the smart tag on the EntityDataSource control and select Configure
Data Source from the pop-up menu. The Configure Data Source wizard will
appear.
6.
Choose AdventureWorksEntities from the list of Named Connections. The
DefaultContainerName will default to AdventureWorksEntities. Click the Next
button.
7.
Select Contacts for the EntitySetName and select Contacts for the
EntityTypeFilter.
8.
Check the boxes to enable updates and deletes.
9.
Click the Finish button.
10. The
entity data source is now configured so it can be bound to a GridView control.
Drag a GridView control onto the form.
11. Click
the smart tag to display the pop-up menu next to the GridView if it doesn't
appear by default.
12. Set
the Choose Data Source list to EntityDataSource1.
13. Check
the boxes next to Enable Paging, Enable Editing and Enable Deleting.
14. Click
the Edit Columns… link from the pop-up menu. You should see all of the fields
listed in the Selected Fields list.
15. Click
on the ContactID field and change its Visible property to False. Do the same
for the NameStyle, EmailPromotion, Phone, PasswordHash, PasswordSalt,
AdditionalContactInfo, rowguid, and ModifiedDate fields. Click the OK button.
16. Your
web form should look like the following image.
17. Right
click on the Default.aspx page and set it as the start up page. Run your
project by pressing F5.
18. You'll
get a message asking if you want to modify the web.config file to enable debugging.
Click the OK button.
The web page should be displayed with the list of contacts
in the table. If you click on the Edit link each cell in that row will become
a textbox and you'll be able to change the value. To commit the changes to the
database click the Update link.