Problem filling DataGrid with a DataTable derived from a DataSet

binodbdrchand

New member
Joined
Sep 8, 2008
Messages
4
Programming Experience
Beginner
Hello all. I've -
1) Have loaded 7 tables in a DataSet (ds is the name) at design time
2) Want to display only certain columns in a DataGrid (dg is the name) with
certain formatting.

Here's what I've got -

VB.NET:
Sub LoadDataGrid()

 Dim dt as New DataTable
 Dim rows() as DataRow

 dt = new DataTable("Tab")
 rows = ds.Tables(0).Select("EmployeeID = '001'")
 dt.Rows.Add(rows)

 dg.DataSource = dt

End Sub

Error :
Input array is longer than the number of columns in this table.

I'd appreciate much needed help.

P.S. - Is there a better way of doing this?
 

Latest posts

Back
Top