Figure 17-19
Click Add, OK, and then Finish. Visual Studio 2008 will ask if you want to regenerate the GridView columns fields and data keys. Click No.
This will make the GridView
control display titles whose pub_id
file match the pub-id
value of the selected publisher in the DropDownList1
control.
The source of the LinqDataSource
control now looks like this:
<asp:LinqDataSource
ID='LinqDataSource1'
runat='server'
ContextTypeName='DataClassesDataContext'
EnableDelete='True'
EnableInsert='True'
EnableUpdate='True'
TableName='titles'
Where='pub_id == @pub_id'>
<WhereParameters>
<asp:ControlParameter
ControlID='DropDownList1'
Name='pub_id'
PropertyName='SelectedValue'
Type='String'/>
</WhereParameters>
</asp:LinqDataSource>
Press F5 to debug the application. When you select a publisher now, all books published by that publisher are displayed in the GridView
control (see Figure 17-20).

Figure 17-20
Making the Publisher Field Editable
Now select a record, and click the Edit link. Notice that the publisher is not editable (see Figure 17- 21).

Figure 17-21
Here's how to make the publisher field editable. In the source view of Default.aspx
, insert the following highlighted code:
<asp:TemplateField HeaderText='Publisher'>
<ItemTemplate>
<%#Eval('publisher.pub_name')%>
</ItemTemplate>
</asp:TemplateField>
This creates a dropdown list within the GridView
control (under the Publisher
column) and displays a list of publishers available.
Press F5 to debug the application again. A title's publisher can now be changed (see Figure 17-22).

Figure 17-22
Building Responsive Applications Using AJAX
One of the challenges developers face in building appealing web applications is overcoming the constant need to refresh entire web pages to update just portions of their content. In the real world, network latencies prevent web applications from refreshing as often as you might want. Typically, when a user submits a request to a web server, the entire page must be refreshed and the user is forced to wait while it makes a round trip to the server even when only a fraction of the page has to be changed. Clearly, this is a key usability issue that developers want to put behind them in their quest to build applications that are more desktop-like in their responsiveness.
Enter AJAX, originally an acronym for Asynchronous JavaScript and XML but increasingly a term that embraces a collection of techniques for creating more responsive and feature- rich web applications. Instead of waiting for web pages to refresh, AJAX-enabled web sites dynamically and asynchronously update portions of the pages, thus providing a much more responsive experience to the user. What's more, with AJAX you can now develop richer applications that draw on the JavaScript and CSS support found in modern web browsers such as Firefox and Internet Explorer (IE) 6 and later. A quick look at the Windows Live Local site (see http://maps.live.com) or Google Spreadsheets (see http://spreadsheets.google.com) should be enough to convince you of the wonders that AJAX can deliver to a user experience.
AJAX is not a product but rather a collection of client-empowering web technologies, including XML, JavaScript, HTTP, the DOM, JSON, and CSS. Writing AJAX-style applications is not easy and has traditionally required that you have an intimate knowledge of client-side scripting languages, most notably JavaScript.
With ASP.NET 3.5, Microsoft has built-in support for AJAX. In the Toolbox, you can find a new tab called AJAX Extensions (see Figure 17-23) containing the various AJAX controls.

Figure 17-23
AJAX Control Toolkit
While ASP.NET 3.5 comes with a built-in set of controls you can use to create AJAX-style web applications, one of the greatest benefits of AJAX is that its framework is extensible, which allows you and other developers to create your own AJAX controls by extending those that already exist. Microsoft encourages this activity and sponsors an open-source-style project — the AJAX Control Toolkit that makes available a set of controls developed by Microsoft and seeks to involve the community in creating more elements to extend the functionality of AJAX. The AJAX Control Toolkit gives you access to a growing collection of robust controls that give you additional AJAX-style functionality beyond that provided by the basic AJAX framework.
You can download the AJAX Control Toolkit from: