Update and Add Data

Create a DataTable Object

Many controls, such as data grids, need to be bound to System.Data.DataTable objects. By default, the Data Access classes generated by Iron Speed Designer do not return DataTable objects. Instead, they return array lists of record objects. This customization shows how to convert an array list of record objects to a DataTable object that can be used to bind to controls such as a Datagrid.
Table Name
Select the database table
Applies to
Page class
''' MyPageLoad sub is called when a page is loaded.
''' The object that raised the load event.
''' The object that contains the event data of the load event.
Private Sub MyPageLoad(ByVal sender As System.Object, ByVal e As System.EventArgs) _
    Handles MyBase.Load    
        If Not Me.IsPostBack Then            
            Dim DataGrid As System.Web.UI.WebControls.DataGrid
            ' "myDataGrid" is the id of the asp DataGrid
            DataGrid = CType(Me.FindControlRecursively("myDataGrid"), System.Web.UI.WebControls.DataGrid)
            If (Not IsNothing(DataGrid)) Then
                ' example of where clause is
                ' whereStr = " myNumericField = 1"
                ' whereStr = " myStrField = '1'"
                Dim whereStr as String = Nothing

                ' Create orderBy clause
                Dim orderBy As BaseClasses.Data.OrderBy = Nothing

                ' Set page index and size
                Dim pageIndex as Integer = 0 
                Dim pageSize as Integer = 1000

                ' Retrieving first 1000 records.
                dataGrid.DataSource = ${${Table Name}ClassName}.GetDataTable(whereStr, orderBy, pageIndex, pageSize)
            End If        
        End If

    Catch ex As Exception
        ' Report error message to the user
        Utils.RegisterJScriptAlert(Me, "UNIQUE_SCRIPTKEY", ex.ToString)  
    End Try    
End Sub

Terms of Service Privacy Statement