Auto generate column always show message when datasource null.

When datasource was null the web page always show this message 

"DataSource must not be empty at initial load since columns are generated from dataSource in AutoGenerate Column Grid"


and this is my aspx

 <ej:Grid ID="grdGroupList"
                runat='server'
                MinWidth="600"
                EnableTheming="true"
                IsResponsive="true"
                AllowScrolling="true"
                AllowSorting="true"
                AllowMultiSorting="true"
                AllowResizing="true"
                AllowPaging="false"
                EnableTouch="true"
                GridLines="None">
                <ScrollSettings Height="410"
                    AutoHide="false"
                    EnableTouchScroll="true" />
            </ej:Grid>

1 Reply

VN Vignesh Natarajan Syncfusion Team October 17, 2018 05:29 AM UTC

Hi Athiwat, 
 
 
Thanks for using Syncfusion products.  
 
 
From your query, we understand that you are facing issue while generating ejGrid with auto Generated columns. The reported pop up will be shown when dataSource is not bounded correctly to grid while rendering with auto generating column. While rendering the Grid, either columns or dataSource must be defined.  
 
For your convenience we have prepared a sample with auto generated columns. 
 
 
 
 
Refer the below code example 
 
 
[aspx] 
<ej:Grid ID="grdGroupList" 
                runat='server' 
                MinWidth="600" 
                EnableTheming="true" 
                IsResponsive="true" 
                AllowScrolling="true" 
                AllowSorting="true" 
                AllowMultiSorting="true" 
                AllowResizing="true" 
                AllowPaging="false" 
                EnableTouch="true" 
                GridLines="None"> 
                <ScrollSettings Height="410" 
                    AutoHide="false" 
                    EnableTouchScroll="true" /> 
            </ej:Grid>    
 
[aspx.cs] 
 
protected void Page_Load(object sender, EventArgs e) 
        { 
            BindDataSource(); 
        } 
 
        private void BindDataSource() 
        { 
            int code = 10000; 
            for (int i = 1; i < 10; i++) 
            { 
                order.Add(new Orders(code + 1, "ALFKI", i + 0, 2.3 * i, new DateTime(1991, 05, 15), "Berlin")); 
                order.Add(new Orders(code + 2, "ANATR", i + 2, 3.3 * i, new DateTime(1990, 04, 04), "Madrid")); 
                order.Add(new Orders(code + 3, "ANTON", i + 1, 4.3 * i, new DateTime(1957, 11, 30), "Cholchester")); 
                order.Add(new Orders(code + 4, "BLONP", i + 3, 5.3 * i, new DateTime(1930, 10, 22), "Marseille")); 
                order.Add(new Orders(code + 5, "BOLID", i + 4, 6.3 * i, new DateTime(1953, 02, 18), "Tsawassen")); 
                code += 5; 
            } 
            this.grdGroupList.DataSource = order; 
            this.grdGroupList.DataBind(); 
        } 
 
 
 
Refer the below screenshot for the output 
 
 
 
 
If you have define the dataSource for the grid and still facing the issue kindly share the following details 
 
  1. Share your server side code (how you have bound the dataSource).
  2. Share the screenshot of script error in the console window if any.
  3. If possible try to reproduce the reported issue in provided sample
  4. Share your essential studio version(XX.X.X.XX)
  
 
Regards, 
Vignesh Natarajan 


Loader.
Up arrow icon