Paging not working in a datagrid

Paging not working in a datagrid

Post by J. Muenchb » Sat, 29 May 2004 01:47:04



I'm trying to use paging in a datagrid, but I can't get past the "cannot
compute Count for a data source that does not implement ICollection"
application error, as it does not point to a line in the code. Does the
same thing even when i change the AllowCustomPaging property to
AllowPaging . Wondering how to enable ICollection for the datasource:

''''
Sub myDataGrid_PageChanger(Source As Object, _
E As DataGridPageChangedEventArgs)
' Set the CurrentPageIndex before binding the grid
myDataGrid.CurrentPageIndex = E.NewPageIndex
BindData
End Sub
''''

<form runat="server" method="post">
<asp:Datagrid runat="server"
Id="MyDataGrid"
GridLines="Both"
cellpadding="0"
cellspacing="0"
Headerstyle-BackColor="#9999ff"
Headerstyle-Font-Name="Arial"
Headerstyle-Font-Size="12"
Headerstyle-Font-Bold="True"
BackColor="#00ffff"
Font-Name="Arial"
Font-Size="11"
BorderColor="Black"
showfooter="true"
footerstyle-BackColor="#9999ff"
footerstyle-Font-Name="Arial"
AlternatingItemStyle-BackColor="#ffffff"
AutogenerateColumns="False"
OnEditcommand="MyDataGrid_EditCommand"
OnCancelcommand="MyDataGrid_Cancel"
OnUpdateCommand="MyDataGrid_UpdateCommand"
AllowCustomPaging="True"
PageSize="10"
PagerStyle-Mode="NextPrev"
PagerStyle-NextPageText="Next ->"
pagerstyle-prevpagetext="<- Previous"
PagerStyle-Font-Bold="True"
OnPageIndexChanged="myDataGrid_PageChanger">

</asp:DataGrid>
</form>
'''''

Thanks in advance
Muench



*** Sent via Developersdex http://www.yqcomputer.com/ ***
Don't just participate in USENET...get rewarded for it!
 
 
 

Paging not working in a datagrid

Post by RGF2aW » Sat, 29 May 2004 02:51:10

The grid datasource has to be class implement ICollection such as arraylist, DataView
If you are using cutomizing page, VirtualPagenumber has to set to the count of the data source

 
 
 

Paging not working in a datagrid

Post by J. Muenchb » Sat, 29 May 2004 05:26:54


arraylist, DataView.
?????????
????

i appreciate your help dave, but can you or anyone be more specific?
thanks
muench

*** Sent via Developersdex http://www.yqcomputer.com/ ***
Don't just participate in USENET...get rewarded for it!
 
 
 

Paging not working in a datagrid

Post by Rick Spiew » Sat, 29 May 2004 10:53:17

What is your datasource? If it is a collection, it should inherit from
collectionbase or another collection type which implements IEnumerable, etc.
 
 
 

Paging not working in a datagrid

Post by J. Muenchb » Sun, 30 May 2004 08:36:39

This is a multi-part message in MIME format



Like the last response, the code you see is what I'm working with.
Without the paging attributes, this script works fine. I have no idea if
youre talking about the namescpae references: <%@ Import
Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQLClient" %>,
or where the Icollection would be .
Thanks
Muench

*** Sent via Developersdex http://www.yqcomputer.com/ ***
Don't just participate in USENET...get rewarded for it!