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
/// This method 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 void MyPageLoad(object sender, System.EventArgs e) 
        if (!this.IsPostBack)
            System.Web.UI.WebControls.DataGrid DataGrid;
            // "myDataGrid" is the id of the ASP DataGrid
            DataGrid = ((System.Web.UI.WebControls.DataGrid)(this.FindControlRecursively("myDataGrid")));
            if (DataGrid!= null)
                // example of wherestr is
                // whereStr = " myNumericField = 1";
                // whereStr = " myStrField = '1'";
                string whereStr = null;

                // Create orderBy clause
                BaseClasses.Data.OrderBy oB = null;

                // Set page index and size
                int pageIndex = 0;
                int pageSize = 1000;

                // Retrieving first 1000 records.
                DataGrid.DataSource = ${${Table Name}ClassName}.GetDataTable(whereStr, oB, pageIndex, pageSize);
    catch (Exception ex)
        // Report error message to the user
        BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(this, "UNIQUE_SCRIPTKEY", ex.Message);
Applies to
CSharpPageConstructor class
    // The following line will be inserted inside the
    // constructor for page class.
    this.Load += new System.EventHandler(MyPageLoad);    

Terms of Service Privacy Statement