Results 1 to 2 of 2

Thread: Cannot Get Datagrid to Bind to Dataset

  1. #1

    Thread Starter
    Hyperactive Member JazzBass's Avatar
    Join Date
    Jun 1999
    Posts
    393

    Question Cannot Get Datagrid to Bind to Dataset

    Hi all,

    I'm having a real hard time getting data from an Access database to be displayed in a datagrid in a webform.

    Here is my code:

    VB Code:
    1. DataGrid1.DataSource = DS.Tables(0).DefaultView
    2.         DataGrid1.DataBind()
    3.         MyDataAdapter.Dispose()
    4.         MyConnection.Dispose()

    I've tried not calling the .Dispose methods at the end, but doesn't make a difference.

    I know this shouldn't be hard, but for some reason, it's not working.

    Prior to this code, I do a response.write (ds.tables(0).Rows.Count) and I get > 0, so it's getting something.

    Does anyone have any suggestions?

    Thanks in advance.
    JB
    JazzBass
    In the .NET era
    Trying to remember VB6
    Progress:
    XP Professional @ Home
    and @ the Office

  2. #2
    Addicted Member nickname's Avatar
    Join Date
    Sep 2004
    Location
    Europe - Belgium
    Posts
    170

    Re: Cannot Get Datagrid to Bind to Dataset

    Hello

    I'm programming ASP.net since a few weeks, so I'm new.. But why not use the SqlDataSource? It works fine for me..

    You bound the SqlDataSource to the gridview..
    You can edit the query that fills the SqlDataSource whenever you want..

    greetz

    nickname
    Software Engineer
    DBA
    Webdesigner
    --
    to code or to be coded, that's the question

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width