I'm getting this error: DataSourceCount is not ready at this moment
when my RadGrid initially has more than the PageSize number of records. My PageSize="20" so I get that runtime error if the initial databind is with more than 20 rows.
Here is the declaration of the grid:
And here's the code that does the binding:
This code is called within the Page_Load event of my aspx page.
when my RadGrid initially has more than the PageSize number of records. My PageSize="20" so I get that runtime error if the initial databind is with more than 20 rows.
Here is the declaration of the grid:
<
oscarcontrols:OscarGrid
runat
=
"server"
ID
=
"grdProcessOrders"
AutoGenerateColumns
=
"false"
Visible
=
"true"
PageSize
=
"20"
AllowPaging
=
"true"
ShowHeader
=
"true"
Width
=
"100%"
AllowSorting
=
"true"
EnableEmbeddedSkins
=
"false"
DataKeyNames
=
"OrdID"
OnPageIndexChanged
=
"grdProcessOrders_PageIndexChanged"
OnPageSizeChanged
=
"grdProcessOrders_PageSizeChanged"
OnItemCommand
=
"grdProcessOrders_ItemCommand"
OnSelectedIndexChanged
=
"grdProcessOrders_SelectedIndexChanged"
OnItemDataBound
=
"grdProcessOrders_ItemDataBound"
OnDataBound
=
"grdProcessOrders_DataBound"
Skin
=
"OSCARGridStyle1"
OnSortCommand
=
"grdProcessOrders_SortCommand"
OnItemCreated
=
"grdProcessOrders_ItemCreated"
>
<
ClientSettings
EnableRowHoverStyle
=
"true"
EnableAlternatingItems
=
"false"
EnablePostBackOnRowClick
=
"true"
>
<%--<
ClientEvents
OnGridCreated
=
"ProcOrdGridCreate"
/> --%>
<
Selecting
AllowRowSelect
=
"True"
/>
<%-- <
ClientEvents
OnRowContextMenu
=
"RowContextMenu"
/> --%>
</
ClientSettings
>
<
PagerStyle
Position
=
"TopAndBottom"
Mode
=
"NumericPages"
Width
=
"100%"
AlwaysVisible
=
"false"
/>
<
MasterTableView
OnPreRender
=
"grdProcessOrders_PreRender"
DataKeyNames
=
"OrdID"
>
<
NoRecordsTemplate
>
<
oscarcontrols:OscarPanel
runat
=
"server"
ID
=
"pnlNoRecords"
Width
=
"100%"
CssClass
=
"procOrdersNoRecordsFound"
>
<
h2
>
<
oscarcontrols:OscarLabel
runat
=
"server"
ID
=
"lblSorry"
Text
=
"Sorry. Try Again."
/></
h2
>
<
oscarcontrols:OscarLabel
runat
=
"server"
ID
=
"lblNoRecords"
Text
=
"There were no records found that matched your search criteria."
/><
br
/>
<
br
/>
</
oscarcontrols:OscarPanel
>
</
NoRecordsTemplate
>
<
PagerTemplate
>
<
table
width
=
"100%"
>
<
tr
>
<
td
style
=
"padding-left: 5px"
>
<
oscarcontrols:OscarLabel
runat
=
"server"
ID
=
"lblResultsFoundValue"
Text='<%# DataBinder.Eval(Container, "Paging.DataSourceCount")%>'
Font-Bold="true" />
<
b
>
<
oscarcontrols:OscarLabel
runat
=
"server"
ID
=
"lblResultsFound"
Text
=
"Results Found."
Font-Bold
=
"true"
/></
b
>
</
td
>
<
td
align
=
"right"
style
=
"padding-right: 5px"
>
<
table
>
<
tr
>
<
td
>
<
oscarcontrols:OscarLabel
runat
=
"server"
ID
=
"lblResultPerPage"
Text
=
"Results per Page:"
/>
<
oscarcontrols:OscarComboBox
ID
=
"ProcOrdRadComboBox1"
DataSource="<%# new object[]{10, 20, 30, 40, 50} %>"
SelectedValue='<%# DataBinder.Eval(Container, "Paging.PageSize") %>' Style="margin-right: 20px;"
Width="40px" runat="server" OnClientSelectedIndexChanged="ProcOrdRadComboBox1_SelectedIndexChanged">
</
oscarcontrols:OscarComboBox
>
</
td
>
<
td
>
<
oscarcontrols:OscarImageButton
ID
=
"Button1"
runat
=
"server"
ImageUrl
=
"~/Images/PagingFirst.gif"
OnClientClick
=
"ProcOrdchangePage('first'); return false;"
CommandName
=
"Page"
CommandArgument
=
"First"
/>
<
oscarcontrols:OscarImageButton
ID
=
"Button2"
runat
=
"server"
ImageUrl
=
"~/Images/PagingPrev.gif"
OnClientClick
=
"ProcOrdchangePage('prev'); return false;"
CommandName
=
"Page"
CommandArgument
=
"Prev"
/>
</
td
>
<
td
>
<
oscarcontrols:OscarPanel
runat
=
"server"
ID
=
"NumericPagerPlaceHolder"
/>
</
td
>
<
td
>
<
oscarcontrols:OscarImageButton
ID
=
"ImageButton1"
runat
=
"server"
ImageUrl
=
"~/Images/PagingNext.gif"
OnClientClick
=
"ProcOrdchangePage('next'); return false;"
CommandName
=
"Page"
CommandArgument
=
"Next"
/>
<
oscarcontrols:OscarImageButton
ID
=
"ImageButton2"
runat
=
"server"
ImageUrl
=
"~/Images/PagingLast.gif"
OnClientClick
=
"ProcOrdchangePage('last'); return false;"
CommandName
=
"Page"
CommandArgument
=
"Last"
/>
</
td
>
</
tr
>
</
table
>
</
td
>
</
tr
>
</
table
>
</
PagerTemplate
>
And here's the code that does the binding:
grdProcessOrders.DataSource = GetSortedOrders(
false
);
grdProcessOrders.DataBind();
This code is called within the Page_Load event of my aspx page.