Reputation: 1623
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.
Upvotes: 0
Views: 5603
Reputation: 11
Here is some code I use this to create client-side events for the built-in buttons in GridView.
protected void Page_LoadComplete(object sender, EventArgs e)
{
MyCommon.GridButtonClientClick(gvLookup, "gclick()");
}
public static void GridButtonClientClick(GridView g, String function)
{
foreach (GridViewRow gvr in g.Rows)
{
Control x = gvr.Cells[0].Controls[0];
LinkButton y = (LinkButton)x;
y.OnClientClick = function;
}
}
Upvotes: 0
Reputation: 4297
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('GridView1','Select$0')">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.
Upvotes: 3