Binding a dataset to DatagridView , db Oslo, Norway
  • 12 years ago


    Anyone help me, how to bind a dataset to a dataset to a dataset to datagridview, in we have .databind property, wat else can be used in windows application?


  • 12 years ago

    DataBind is a method, not a property.  In Windows forms you just set the DataSource property.  In the case of a DataSet, you'd need to set the DataMember to the name of the DataTable too.

    That said, you should use a BindingSource as an intermediary.  Bind the DataTable to the BindingSource via its DataSource and DataMember properties, then bind the BindingSource to the DataGridView. 

  • 12 years ago

    Thanks for the help,

    I tried by setting the DataMember and it worked fine.... but in this case i just used a single table, so I used the table name, what if im retrieving data from more than one table? what must be used as the datamember?

  • 12 years ago

    The DataMember is assigned the name of the DataTable, not the table in the database.  You can only bind one DataTable.  Whether or not the data in that DataTable comes from 1, 2 or 100 different tables in the database is irrelevant. 

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Most software today is very much like an Egyptian pyramid with millions of bricks piled on top of each other, with no structural integrity, but just done by brute force and thousands of slaves” - Alan Kay