Hi,
do you want to create DataTable manually and bind it to the datagrid. Here is the code:
#Region "buildDataTable - Building Own DataTable"
Public Function buildDataTable() As DataTable
'Instantiating DataTable object
PrivateDataTable = New DataTable("tblAccounts")
'Create table structure
PrivateDataCol = New DataColumn
PrivateDataCol.ColumnName = "AccName"
PrivateDataCol.DataType = System.Type.GetType("System.String")
'Add column to data table structure
PrivateDataTable.Columns.Add(PrivateDataCol)
'Add column to pk array
PrivateDclPrimaryKey(0) = PrivateDataCol
'Set Primary key
PrivateDataTable.PrimaryKey = PrivateDclPrimaryKey
'Add Debit column
PrivateDataCol = New DataColumn
PrivateDataCol.ColumnName = "Debit"
PrivateDataCol.DataType = System.Type.GetType("System.String")
'Add column to data table structure
PrivateDataTable.Columns.Add(PrivateDataCol)
'Add Credit column
PrivateDataCol = New DataColumn
PrivateDataCol.ColumnName = "Credit"
PrivateDataCol.DataType = System.Type.GetType("System.String")
'Add column to data table structure
PrivateDataTable.Columns.Add(PrivateDataCol)
Return PrivateDataTable
End Function
#End Region
Creating dataTable manually in Visual Basic 2005