Click to See Complete Forum and Search --> : Sorting Results of a Query String


sitehatchery
03-15-2006, 04:28 PM
Code in C#


case "cat": //Category

.....

if(intValue == -1)
{
bolVisiable = true;
rptProduct.DataSource = Product.SelectAll((Request.QueryString["page"] == null ? -1: Convert.ToInt32(Request.QueryString["page"])));
rptProduct.DataBind();
}
else
{
rptProduct.DataSource = Product.ReturnByCategory(intValue, (Request.QueryString["page"] == null ? -1: Convert.ToInt32(Request.QueryString["page"])));
rptProduct.DataBind();
}

.....


Tried, searched and tried to sort the results of this string query. It calls a stored procedure. But I have to sort it after the stored procedure because sorting within the stored procedure screws everything up. Anyway, I want to sort it in the source code.

I think I need to directly sort the array before it is applied to the rptProduct.Datasource object. Looking at the MSDN library, I don't see that there is a way to apply a sort to the Databind() method directly. Alternatively, according to MSDN, "you call the Repeater control's DataBind method to get the records to be displayed". So, it might make sense to call a sorting method after the DataBind() method has finished retrieving the records.

The repeater class is part of System.Web.UI.WebControls.

The closest example I could find is found here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWebUIWebControlsDataGridSortCommandEventArgsClassTopic.asp.

Still, I've looked at this for quite some time and I can't seem to figure it out. Any thoughts?