Building an UltraGrid into customization

I am currently trying to build an UltraGrid into my customization programmatically. The following is what I have. The first part builds the columns okay but when I try to add a row with data in it, that doesn’t show up. I’ve tried a few things with no luck. Can anyone see what I have wrong.

DataTable dtColumnHeaders = new DataTable(“Column Header Table”);
// Declare variables for DataColumn and DataRow objects.
DataColumn dcColumn;

    // "Serial Number"
    dcColumn = new DataColumn();
    dcColumn.DataType = System.Type.GetType("System.Int32");
    dcColumn.ColumnName = "SerialNumber";
    dcColumn.Caption = "Serial Number";
    dcColumn.ReadOnly = true;
    dcColumn.Unique = true;
    dtColumnHeaders.Columns.Add(dcColumn);

	// "Date Created"
	dcColumn = new DataColumn();
    dcColumn.DataType = System.Type.GetType("System.Int32");
    dcColumn.ColumnName = "DateCreated";
    dcColumn.Caption = "Date Created";
    dcColumn.ReadOnly = true;
    dcColumn.Unique = true;
    dtColumnHeaders.Columns.Add(dcColumn);

	// "Consume"
	dcColumn = new DataColumn();
    dcColumn.DataType = System.Type.GetType("System.Int32");
    dcColumn.ColumnName = "Consume";
    dcColumn.Caption = "Consume";
    dcColumn.ReadOnly = true;
    dcColumn.Unique = true;
    dtColumnHeaders.Columns.Add(dcColumn);

	setgriddata dSetDataGrid = SetDataGrid;
    DataGrid.Invoke(dSetDataGrid, DataGrid, dtColumnHeaders);

/************* Start building data row here ******************/

	DataSet ds = new DataSet(); 
	DataTable dt1 = new DataTable("Table");
	DataGrid.DataSource = ds;
    
	ds.Tables.Add(dt1); 

	DataColumn column1 = new DataColumn("Column 1", typeof(string));
	DataColumn column2 = new DataColumn("Column 2", typeof(string));
	DataColumn column3 = new DataColumn("Column 3", typeof(string));

	//Add the three columns to the table.
	dt1.Columns.AddRange(new DataColumn[] { column1, column2, column3 });

	//Add the table to the dataset.
	ds.Tables.Add(dt1);

	UltraGridRow row = DataGrid.DisplayLayout.Bands[0].AddNew();
	row.Cells[0].Value = "Plastic";
	row.Cells[1].Value = "10/16/2020";
	row.Cells[2].Value = "No";
	
	DataGrid.DataSource = ds;

How about adding DataGrid.DataBind() at the end ?

I will try that. Thanks.

Adding DataGrid.DataBind() didn’t solve my problem but thank you anyway. I will continue to try to find a solution.

The best way to do this is to build a data table with the columns and the data then make it the data source for the ultragrid. I have a few customizations I do this way.

If you want some sample code let me know I can provide some base on your code.

Thanks
Matt

Reading your code again though it appears you are setting the datasource to the dataset not the table. Sorry about missing that. Change DataGrid.DataSource = ds; to DataGrid.DataSource = ds[“Table”];
This will assign “Table” table to the grid view rather than the dataset

You should make a new EpiDataView.
Add your new EpiDataView to oTrans.
Then set the EpiDataView.dataVeiw = yourTable.DefaultView.
Then all the UI bindings are done in the normal way.

Hello,
the code should be like as below
Dim edvOD as EpiDataView = new EpiDataView
edvOD.dataview = new dataview(ds.Tables(0))

			grid.DataSource = edvOD.dataview
			grid.DataBind()