How to add empty row in a datagrid.
* Create and add an empty Row for a Data Table.
* Assign the Datatable as dataSource for the datagrid.
* Bind the datagrid.
#VB.NET
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dt as new DataTable
dt.rows.add(dt.NewRow())
DataGrid1.DataSource = dt
DataGrid1.DataBind()
End Sub
If we need just a template of a datagrid at runtime means, just bind an empty DataTable like below
#VB.NET
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dt as new DataTable
DataGrid1.DataSource = dt
DataGrid1.DataBind()
End Sub
No comments:
Post a Comment