views:

110

answers:

2

Hi, I've very small question that drives me mad :)

I've a Gridview (bind from db nothing special there) and I use small function that runs on the griviewrows and sets .Visable to false in case they don't match search criterias. It works fine but when I try to sort the grid view (by clicking on the header) all the "hidden" rows shows up again. I tried to use the "GridView_Sorted" event in order to run on the gridview and hide again but it doesn't seem to do anything. The select statement is stored procedure so I can't use filtering expressions.

My Question is - Is there a way to run the hiding function after the sort (as "Occurs when the hyperlink to sort a column is clicked, but after the GridView control handles the sort operation." {http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.sorted.aspx} suggests )

+1  A: 

The GridView's PreRender event should do the trick.

You could just walk GridView.Rows and apply your logic there... That way it's guaranteed to occur at the right time wether the sort happens or not.

Brian MacKay
no luck - The PreReinder runs and still all the rows are shown
TheSimon
it was my mistake :)
TheSimon
A: 

How are you binding the data? Maybe it would help only to bind the used data (rows) to the grid, because binding not displayed data is kind of an overhead.

griti