Assignment 4

LINQ

Instructions

Create a new web site

Before you add the LINQ elements you will need to create a connection. From the VIEW menu, open the Server Explorer. In the Server Explorer create a new connection to .\sqlExpress\CommunityAssist.

Add a LINQ to SQL to the web site

Drag the Person and the ServiceGrant tables onto the the LINQ designer form. Save Everything

On the Default.aspx form drag a DropDownList control and a DataList control.

Use the Page Load event and LINQ code to fill the DropDownList with PersonKeys from the ServiceGrant table. (Add a distinct to the end to list only one instance of each key.)

Set the AutoPostback property of the DropdownList to "true."

In the SelectIndexChanged event of the DropDownList control write the lINQ code to fill the DataList control with the grant information for the selected personkey. The page should look like this:

Assignment 4 web page

You will have to manually create an item template for the DataList. If you used a label control, the code for the LastName field would lool like this:

<asp:Label ID="lblLastName" runat="Server" Text='<%#Eval("LastName")%>'/>

Grading

The assignment is worth 10 points

  • 2 points for adding the LINQ to SQL and classes
  • 3 points for filling the drop down list
  • 3 points for LINQ code for DataList
  • 2 points for DataList template