Data Table/ Datagridview population

Issues with getting column to get data from data table

Page 1 of 1

1 Replies - 3819 Views - Last Post: 02 September 2010 - 07:52 PM Rate Topic: -----

#1 mjw85  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 52
  • Joined: 01-October 07

Data Table/ Datagridview population

Posted 02 September 2010 - 01:13 PM

Hello,
I am currently using c# in Visual Studio - working with a datagridview and a datatable. I am trying to get the datagridview to get the data from a column in the data table created, but am having an issue with the following code... just kinda confused as what needs to go where. I want a column in the datagridview to get the data from a column in the data table... Thanks for your help!
(StockNumber is the name of the column in the datagridview I want populated)


 
DataRow[] foundRows = dtItemDetails.Select();
foreach (DataRow drItemDetails in foundRows)
{
dataGridView.ColumnCollection.Add();
}


Is This A Good Question/Topic? 0
  • +

Replies To: Data Table/ Datagridview population

#2 demausdauth  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 179
  • View blog
  • Posts: 655
  • Joined: 03-February 10

Re: Data Table/ Datagridview population

Posted 02 September 2010 - 07:52 PM

Is there a reason you can't bind the DataTable to the DataGridView?

How to: Bind Data to the Windows Forms DataGridView Control

The example above uses a BindingSource, but you can simple set the DataSource property at the very least.

This post has been edited by demausdauth: 02 September 2010 - 07:54 PM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1