I have a RadGrid on an ASP.NET page and the sorting of the rows for each page does not always work properly. For example, I have one grid with 359 rows, the grid's page size is 50, and the column being sorted is a DateTime field. So for 359 rows at 50 each the grid properly breaks things up into 8 pages. When you go to pages 1-4 and 6-8, each page's rows are properly sorted in descending order. When you go to page 5 the rows seemed to be sorted by "date string" order, instead of being sorted the normal DateTime way they sure appear to be sorted in their string order (where the format is "MM/DD/YYYY").
I've used SQL Manager to look at the data returned from the query and each page appears to have the proper rows, just page 5 is not sorted correctly. The control is fed the entire set of data (all 359 rows) any time "needs data" is called, so it is the control that is figuring out which 50 of the set need to be displayed and in what order.
Here's what I think is the pertinent markup:
I added the AllowNaturalSort="False" to the MasterTableView today; I get the same results with or without that tag.
The only binding of the control is when the page is initialized, and in that case a Rebind is called.
The "need data" event simply gets the data from the database into an array of class objects and is bound like this:
The item data bound formats some columns, but doesn't touch the date column.
Any ideas appreciated, and if I can supply any further info please let me know.
I've used SQL Manager to look at the data returned from the query and each page appears to have the proper rows, just page 5 is not sorted correctly. The control is fed the entire set of data (all 359 rows) any time "needs data" is called, so it is the control that is figuring out which 50 of the set need to be displayed and in what order.
Here's what I think is the pertinent markup:
<
telerik:RadGrid
ID
=
"InvoicesGrid"
runat
=
"server"
Skin
=
"Sullivans"
EnableEmbeddedSkins
=
"false"
CellPadding
=
"3"
GridLines
=
"None"
AlternatingItemStyle-CssClass
=
"orderAltRow"
AutoGenerateColumns
=
"False"
AllowSorting
=
"True"
AllowMultiRowSelection
=
"False"
AllowPaging
=
"True"
OnNeedDataSource
=
"InvoicesGrid_NeedDataSource"
OnItemDataBound
=
"InvoicesGrid_ItemDataBound"
OnPageIndexChanged
=
"InvoicesGrid_PageIndexChanged"
>
<
PagerStyle
Mode
=
"NextPrevNumericAndAdvanced"
></
PagerStyle
>
<
MasterTableView
Width
=
"100%"
DataKeyNames
=
"Header.Invoice_No"
AllowMultiColumnSorting
=
"False"
ShowFooter
=
"true"
AllowNaturalSort
=
"False"
>
<
Columns
>
<!-- Bunch of columns removed. -->
<
telerik:GridBoundColumn
DataField
=
"Header.Invoice_Dt"
HeaderText
=
"Date"
DataFormatString
=
"{0:d}"
Aggregate
=
"None"
DataType
=
"System.String"
/>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
I added the AllowNaturalSort="False" to the MasterTableView today; I get the same results with or without that tag.
The only binding of the control is when the page is initialized, and in that case a Rebind is called.
The "need data" event simply gets the data from the database into an array of class objects and is bound like this:
InvoicesGrid.DataSource = details;
The item data bound formats some columns, but doesn't touch the date column.
Any ideas appreciated, and if I can supply any further info please let me know.