problem with PagdDataSource (new vesrion)

Discussion in 'ASP .Net Datagrid Control' started by Chris, Feb 7, 2007.

  1. Chris

    Chris Guest

    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.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
    Chris

    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.ConnectionStrings("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>
    Chris, Feb 7, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robb Smith
    Replies:
    2
    Views:
    560
    Saravana
    Jul 18, 2003
  2. =?Utf-8?B?UGF0cmljaw==?=

    Open new with new session

    =?Utf-8?B?UGF0cmljaw==?=, Dec 18, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    3,322
    tittlejoseph
    Sep 2, 2007
  3. Rolf Welskes
    Replies:
    3
    Views:
    531
    Steven Cheng[MSFT]
    Oct 12, 2006
  4. Zak Kinion
    Replies:
    0
    Views:
    301
    Zak Kinion
    Nov 2, 2010
  5. Replies:
    2
    Views:
    439
    Thomas 'PointedEars' Lahn
    Mar 11, 2008
Loading...

Share This Page