PagedDataSource: what's wrong in this code?
Hi,
I posted this topic yesterday but i correct a lot myself, still with the same error(s). So i post it again. Thanks.
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.DataSet' to type 'System.Collections.IEnumerable"
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
H.
code-behind:
-----------
Dim PageDataSource As New PagedDataSource()
Dim ds As DataSet
Dim d As SqlDataAdapter
Dim sql As String
Dim sConnectionString As String
Dim x As Integer
Dim p As String
sConnectionString = System.Configuration.ConfigurationManager.Connecti onStrings("prod").ToString()
sql = "SELECT * FROM [Product]"
d = New SqlDataAdapter(sql, sConnectionString)
ds = New DataSet()
x = d.Fill(ds)
p = ds.Tables(0).ToString
PageDataSource.DataSource = ds
'PageDataSource.DataSource = p
PageDataSource.AllowPaging = True
PageDataSource.PageSize = 4
DataList1.DataSource = PageDataSource
DataList1.DataBind()
aspx file:
---------
<asp:DataList ID="DataList1" runat="server">
<ItemTemplate>
.....
</ItemTemplate>
</asp:DataList>
|