Display headers in Infragistics ULTRAGRID if there is no data in the table

I am retrieving data from an SQL table using a DataSet in VB.Net. When there is data in the table, it correctly displays the data in the grid, but when there is no data in the table, only the main UltraGrid view is displayed in it.

How to display table column names as UltraGrid headers, even if the table has no data?


Thanks for the answer, but I think the problem JD is facing is slightly different from mine - in my application, the data was correctly retrieved from SQL Server. My problem is that when there is no data in the table, I want to display the columns of the table as grid headers with 0 rows. This is not happening.

It just shows a message box saying that no data was found, and UltraGrid shows how this is done by default in the application.

+3
source share
3 answers

This is discussed in this forum forum Infragistics .

0
source

Do you know that column headings will or will be dynamic based on the data in the table? If you know in advance, you can create columns with the appropriate headings in an empty data set and assign it to the grid data source.

0
source

I notice the same behavior when I manually create a datatable and assign it as a grid data source. If the data table is empty, all column header information that was previously set in the grid is lost. My solution to this was to never give it an empty table unless I have rows in my table, at least all the columns are defined.

DataTable table = new DataTable("fooTable");
table.Columns.Add("fooCol1", typeof(long));
table.Columns.Add("fooCol2", typeof(string));
table.Columns.Add("fooCol3", typeof(bool));
myUltraGrid.DataSource = table;

By never setting the grid to an empty table, you save the header information.

0
source

All Articles