neuDev33 neuDev33 - 1 month ago 14
ASP.NET (C#) Question

What client-side events does the standard ASP.NET GridView have?

I've implemented a GridView that is within an UpdatePanel whose trigger is the GridViews SelectedIndexChanged event. As expected, it works very slow. I'd instead like to handle this on the client-side, but cannot find enough information on what client-side events a GridView supports. Can anyone point out any references where this information may be available?

EDIT: Even if anyone knows any client-side events off the top of their heads, I'd be interested.

Answer

What client-side events does the standard ASP.NET GridView have?

I'd be happy to be proven wrong by another response, but... none? It's a server-side object with no client-side javascript object representation. This is typical of most standard ASP.NET WebForms controls.

Drop a GridView on a WebForm and add a column <asp:CommandField ShowSelectButton="true" /> Client-side, this looks like: <td><a href="javascript:__doPostBack(&#39;GridView1&#39;,&#39;Select$0&#39;)">Select</a></td>

There's no client-side event on any object that you can handle, it's just an anchor with a javascript snippet calling a postback. If you're wanting something more fancy, you're going to have to bake something yourself, like - http://weblogs.asp.net/andrewrea/archive/2008/08/04/gridview-row-click-selection-via-clientside-code.aspx

The alternative, is to move to another ASP.NET WebForms "Grid" control. I know the DevExpress grid for example has a rich client-side object model. I'm almost certain Telerik has similar, and there's probably a few others out there.