Create Temporary data using datatable

By bryan tugade

You can create a temporary data to bind in gridview, datalist and formview.

   Public Function bindTempData() As System.Data.DataTable
        Dim objDataTable As New System.Data.DataTable

        objDataTable.Columns.Add("studentid", String.Empty.GetType())
        objDataTable.Columns.Add("name", String.Empty.GetType())

        objDataTable.Rows.Add(New String() {"studid1", "aaa"})
        objDataTable.Rows.Add(New String() {"studid2", "bbb"})
        objDataTable.Rows.Add(New String() {"studid3", "ccc"})

        Return objDataTable
    End Function

Then you can bind it usingobjectdatasource or in code behind.

Create Temporary data using datatable  (1115 Views)