AJAX-Enabling a GridView Control with Atlas
In my last post, I pointed out some of the problems with AJAX. In this post, I'll show you to take the ASP.NET GridView control and AJAX-enable it in about 30 seconds using Microsoft's new Atlas framework.
The GridView control is one of the most powerful and commonly used components of the .NET framework. With it, we can easily display data from a datasource such as SQL Server and enable things like sorting, editing, paging, and deleting. All of this can be done with little or no code. Every time you execute a GridView function (such as switching pages) a postback occurs and the entire page reloads. Wouldn't it be great if we could update the GridView dynamically without the need for a postback every time?
The Atlas framework makes this not only possible, but extremely simple.
Step 1 – Download and install the Atlas Framework
Step 2 – Create a new Atlas project and make a new web form with a GridView control bound to a datasource. The Northwind database will work well for this.
Step 3 – Add an Atlas ScriptManager Control to the page and enable partial rendering.
<atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="True" />
Step 4 – Surround your GridView control with an Atlas UpdatePanel conrol.
<atlas:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server" ... />
</ContentTemplate>
</atlas:UpdatePanel>
Step 5 – Save it. Run it. Marvel at how simple that was.