I'm at the point where I'm starting to use my business object library by web pages.
I'm using a GridView control for the first time and everything seemed really easy and straightforward until I started to test the sorting. It doesn't sort.
I have the AllowSorting="True" defined in the gridview tag, and I have SortExpression="thePropertyName" defined in the bound field tags.
Any clues? I'm using caching per the ResourceList.aspx page example if that is mucking things up.
The documentation in the book I'm using says what I did above is all that's needed...
I created a gridview_sorting and gridview_sorted event handlers. Debugging shows that gridview_sorting is receiving the correct sort criteria...
I tried issuing a databind and also removing the cache and then databinding, but no change in behavior.
My colleague just came in and said, "Did you search for an answer?"
Duh.
Obviously, she metabolizes caffiene faster than I do. Or she's smarter than me... :(
See this thread.
This took me several hours to figure out and it seems pretty stupid but all you have to do is add
a OnGridView_Sorting Event to fire .... my code looks like this after setting a datasource
try
{
this.gvProject.DataBind();}
catch{
//No rows , so alternate report sentNoActualData =
true;gvProject.Visible =
false;}
if (this.gvProject.Rows.Count > 0) try{
String sort = this.gvProject.SortExpression; this.gvProject.Sort("PID", SortDirection.Descending);}
catch (Exception ex){
ex.ToString();
}
protected
void gvProject_Sorting(object sender, GridViewSortEventArgs e){
if(e.SortExpression == "WBS" && this.gvProject.SortDirection == SortDirection.Ascending ){
this.gvProject.Sort("WBS", SortDirection.Descending);}
}
Copyright (c) Marimer LLC