The routine retuns a datatable to be bound to the gridview.
With various breaks set in my code and running in debug here is what I see happening, and the various tests I have done:
1 - When the user first hits the "SearchMode" the search fields are drawn and the execSearch returns nothing as no data was posted.
2 - The user enters search data, and clicks find now.
3 - The pagepostsback Still in SearchMode the Keywords field now has a string value, so execSearch fires, setting up the objectDatasource, and gridview and returns it.
4 - SearchMode sees execSearch returned a gridview and runs the gridviews DataBind method.
5 - The ByKeywords Method from the DAL fires. piAcct has a value, srchCriteria has a value (Both Dynamically add as parameters during execSearch()),
SortCriteria is empty, maximumrows is an integer from the form indicating how many records per page, and startRowIndex is 0 as this has not been paged yet.
6 - The query is built by the function and run against the Database. SortCriteria is checked for a value and SHOULD add an Order By clause if it has a value.
7 - The datatable is returned to the objectdatasource, the objectdatasource is returned to the grid, and the grid is returned to the calling procedure.
8 - As I mentioned the paging works, so I won't discuss it.
9 - The user clicks a column header to sort.
10 - The page posts back, The execSearch function runs again creating the initial gridview with search data and returning it.
11 - Then the Sorting event fires, in the sorting event I grab the sortexpression and sortdirection and format it into a proper statement for sql.
Then I get a reference to the objectdatasource by declaring the sender object as a gridviiew, then declaring a type variable as the sender.datasource
Then I add the SortCriteria to the selectparameters.
12 - I then call databind, which fires the ByKeywords method. A break at this point shows me that SortCriteria is still coming up empty.
I have performed some testing at this phase. To see if what I was doing with the objectdatasource in the Sorting event was working, I added a made up
select parameter "objsearch.selectParameters.Add("Test","Test")
After doing that and calling databind, I got an Error that it could not find a "non-generic" method ByKeyword that had "Test" as a parameter.
So I know what I do at the Sorting event to the objectdatasource is being received and used.
So now, when I assign the selectparameter with the "SortCriteria" name, it doesn't give me an error. So to me the logic of this is that, yes
my SortCriteria is being added to the SelectParameters, and yes, the objectdatasource recognizes it is the SortParameter. And yes it calls the ByKeywords
method, but it passes an empty value in as the SortCriteria despite there being a parameter there.
Why is the objectdatasource ignoring what I have explicitly placed into the parameters? How can I correct this?
It is obvious to me from reading that the functionality is there and intended to do exactly what I am doing with it.
I really don't want to have to create a DataView or anything in memory then sort that as it would cause me some
design issues with how to get the Variables needed to execute the ByKeywords search.
Some additional info if it matters: Visual Studio 2005, ASP.NET 2.0.50727
Thanks,
Steve