Binding a dataset to DatagridView

asp.net , db Oslo, Norway
  • 11 years ago

    Hi,

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

     

  • 11 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. 

  • 11 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?

  • 11 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).

Contribute

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.

“Every language has an optimization operator. In C++ that operator is ‘//’”