Hi,
I try to implement paging with PagedDataSource but i get two different
errors:
with the line: "PageDataSource .DataSource = ds" i get the error:
"Unable to cast object of type 'System.Data.Da taSet' to type
'System.Collect ions.IEnumerabl e"
with the line: "PageDataSource .DataSource = p" i get the error:
"Cannot compute Count for a data source that does not implement ICollection"
I thougt Dataset implements class IEnumerable ...
Can anybody tell me what to change in this code?
Thanks
Chris
code-behind:
-----------
Dim PageDataSource As New PagedDataSource ()
Dim ds As DataSet
Dim d As SqlDataAdapter
Dim sql As String
Dim sConnectionStri ng As String
Dim x As Integer
Dim p As String
sConnectionStri ng =
System.Configur ation.Configura tionManager.Con nectionStrings( "prod").ToStrin g()
sql = "SELECT * FROM [Product]"
d = New SqlDataAdapter( sql, sConnectionStri ng)
ds = New DataSet()
x = d.Fill(ds)
p = ds.Tables(0).To String
PageDataSource. DataSource = ds
'PageDataSource .DataSource = p
PageDataSource. AllowPaging = True
PageDataSource. PageSize = 4
DataList1.DataS ource = PageDataSource
DataList1.DataB ind()
aspx file:
---------
<asp:DataList ID="DataList1" runat="server">
<ItemTemplate >
.....
</ItemTemplate>
</asp:DataList>
I try to implement paging with PagedDataSource but i get two different
errors:
with the line: "PageDataSource .DataSource = ds" i get the error:
"Unable to cast object of type 'System.Data.Da taSet' to type
'System.Collect ions.IEnumerabl e"
with the line: "PageDataSource .DataSource = p" i get the error:
"Cannot compute Count for a data source that does not implement ICollection"
I thougt Dataset implements class IEnumerable ...
Can anybody tell me what to change in this code?
Thanks
Chris
code-behind:
-----------
Dim PageDataSource As New PagedDataSource ()
Dim ds As DataSet
Dim d As SqlDataAdapter
Dim sql As String
Dim sConnectionStri ng As String
Dim x As Integer
Dim p As String
sConnectionStri ng =
System.Configur ation.Configura tionManager.Con nectionStrings( "prod").ToStrin g()
sql = "SELECT * FROM [Product]"
d = New SqlDataAdapter( sql, sConnectionStri ng)
ds = New DataSet()
x = d.Fill(ds)
p = ds.Tables(0).To String
PageDataSource. DataSource = ds
'PageDataSource .DataSource = p
PageDataSource. AllowPaging = True
PageDataSource. PageSize = 4
DataList1.DataS ource = PageDataSource
DataList1.DataB ind()
aspx file:
---------
<asp:DataList ID="DataList1" runat="server">
<ItemTemplate >
.....
</ItemTemplate>
</asp:DataList>