Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
SQL Server

How to create a Data Table at Run Time

Author: DevASP
Download Source Code : 361_Data

This article is about how you can make a data table at run time in VB.Net. How you can set its columns, how you can add new rows to the data table and finally how you can get and set values.

  • Steps you will do.
  • Start visual studio and create a new window application.
  • Set the following properties of form.
Text =’Data Table’
  •  Drop a Datagrid control on your form and set its following properties.


Name = ‘dgTable’

Dock = ‘Fill’

Modifires = ‘Friend’

Now open your code window and write the following code in the load event of the form. This code will create a new data table object, make columns, make rows, assign values to these rows and finally assign the data table to the datagrid to display the data.


Dim dt As New DataTable("Students")

dt.Columns.Add("First Name")

dt.Columns.Add("Last Name")


dt.Rows.Add(New Object() {"John", "Browns", "Engineer"})

dt.Rows.Add(New Object() {"Smith", "Gold", "Doctor"})

dt.Rows.Add(New Object() {"Ayna", "Brines", "Author"})

dt.Rows.Add(New Object() {"Donalds", "Gray", "Unknown"})

dgTable.DataSource = dt

Article Comments
Just give full description about datatable and how to create and initialize its vales in datatable using .net

Posted on 2/8/2007 4:12:54 AM by deepi

Back up

Dim dirpath As String
dirpath = Server.MapPath("D:/' " & txtdate.Text & " ' ")
Dim objsearch As DirectoryInfo
objsearch = New DirectoryInfo(dirpath)
If (Not objsearch.Exists) Then
End If

error: virtual path is not correct

Posted on 4/14/2010 2:51:27 AM by priya

how can i insert multiple record in datagridview in

plz send me a coading of gridview

in advace thank u

Posted on 4/14/2010 2:53:17 AM by priya

Add Article Comment:
Name :
Email Address :
Comments :
<< Sending an E-Mail from Client to Server

Disclaimer - Privacy
© 2002-2017