Welcome Guest Search | Active Topics | Sign In | Register

Grid ColumnSort not fired Options
Simon
Posted: Friday, December 10, 2010 11:39:03 AM
Rank: Newbie
Groups: Member

Joined: 12/10/2010
Posts: 2
Hi is there an issue with the grid events?

I have to create a grid dynamically and assign an event to the grid event ColumnSort
Add a number of columns, allow them to be sortable and bind a list to the grid before passing into a placeholder in a user control.

I have used the following exposed eventhandler but it's not being triggered. Am I going wrong somewhere?
Code: C#
grid2.ColumnSort += new EO.Web.GridColumnEventHandler(grid2_ColumnSort);

protected void grid2_ColumnSort(object sender, EO.Web.GridColumnEventArgs e)
{
  System.Diagnostics.Debug.WriteLine("sorted");
}


It only seems to work if the grid is created on the aspx page and the following code is included
Code: HTML/ASPX
oncolumnsort="grid2_ColumnSort"
which isn't much use to me.
eo_support
Posted: Friday, December 10, 2010 3:41:50 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

There is no difference for the two cases from the Grid's point of view. When you declare it directly in your .aspx file, ASP.NET compiler generates the code to attach a handler to the ColumnSort event. When you do it in your code, you attach a handler to the ColumnSort event. In both scenarios the Grid takes an event handler and fires it.

The most likely cause for your problem is your did not reattach the event handler properly when the page posts back (or didn't even recreate the Grid). Whenever you dynamically creating controls, the control tree during the post back stage must be exactly the same as the original stage. Otherwise the event will not be properly rerouted. This is a general ASP.NET rule and it has nothing to do with any of our controls.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.