Grid not showing when data source is empty

Jul 28, 2010 at 12:25 PM
Edited Jul 28, 2010 at 12:26 PM

When the data source is empty (but not null), like an DataTable with no rows, the grid doesn't show and the page gets stuck. The page manager shows simply the loading image.

In the following example, the method FullDataTable doesn't return any rows and the page is therefor not displayed, if the marked row is enabled, the page is displayed appropriately. Attempting to hide the grid doesn't work as well.



    <form id="form1" runat="server">
    <ext:PageManager ID="pageManager1" runat="server" />
    <ext:Grid ID="Grid1" runat="server" EnableCheckBoxSelect="true" EnableRowNumber="true"
            <ext:BoundField ColumnID="r" DataField="Value" />

Code behind:



 protected void Page_Load(object sender, EventArgs e)
            Grid1.DataSource = FullDataTable();

        protected DataTable FullDataTable()
            DataTable newTable = new DataTable();
            newTable.Columns.Add(new DataColumn("Value", typeof(int)));
            DataRow newRow = newTable.NewRow();
            newRow["Value"] = 1;
            //newTable.Rows.Add(newRow); if this row is enabled, the grid shows succesfully.
            return newTable;