Recently, I've run across several posts over at the AJAX.NET Google Group asking about how you can bind a DataGrid, or a Repeater using AJAX.
The answer is, you can't.
DataGrids and Repeaters are Server Side controls. Their life begins and ends on the server, when the page is rendered to the client. The client is rendered to HTML, and sent to the client. That's it. Finito. The End. That's all she wrote. From there on out, it's all the client.
Any AJAX transactions that take place must be rendered on the client using JavaScript. It's that simple. Server Controls are for the server. Asynchronous JAVASCRIPT and XML. No mention of server controls in the name. So, if you bring back a collection of Data from the server, you need to parse through that data with JavaScript, and create your HTML manually. No way around it. (Well, there is, but it can severely limit functionality).
The other issue is Page Context. You don't get one when you're doing an AJAX call on the server. It's an HTTP Request. No page context. With the AJAX.NET library, you get the session and cookies, etc, but the page doesn't exist. No way around that. Even if you could get the page context, it's only valid when the script is running on the server. You can't re-bind data to an existing datagrid.
So, Server Controls are for the Server. Any work done with AJAX is Client Side.
Print | posted on Saturday, March 11, 2006 1:25 AM