Thursday, April 17, 2008

Adding Empty Row to a Data Grid

Here we are going to see how to add empty row in a datagrid. First create an empty Data Row for a Data Table. Assign the Datatable as dataSource for the datagrid. Then bind the datagrid. Code is in VB.Net to add empty row is as follows.

#VB.NET

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim dt as new DataTable
Dim dr as DataRow
dr = dt.NewRow()
DataGrid1.DataSource = dt
DataGRid1.DataBind()

End Sub

No comments: