We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Autogenerate Columns From SQL Server Stored Procedure

Hi there,

I have a stored procedure that generates results and programmatically assigns values to the 'headers' based on what week of the year it is. (Current Week, and Weeks 1 -52 depending on where we are in the year).

As a result, I cannot hard code the column headers in the Syncfusion Grid - the values need to be automatically assigned.

In ASP the Gridview control has a 'AutoGenerateColumns'  property that can be set to 'true' to do this.

https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.gridview.autogeneratecolumns?view=netframework-4.8

Is it possible to do something similar using the Syncfusion Grid control?

Thanks again,

Alex

3 Replies

MP Manivannan Padmanaban Syncfusion Team May 24, 2019 10:15 AM UTC

  
Hi Alex, 
  

Thanks for contacting Syncfusion Support. We are happy to assist you. 

Query:  I cannot hard code the column headers in the Syncfusion Grid - the values need to be automatically assigned. 

From the above query, we are able to understand that you want to load the grid columns automatically based on the dataSource. By default, the columns are automatically generated when Columns declaration is empty or undefined while initializing the Grid. Also, all the columns which are in DataSource are bound as a Grid columns. 

Kindly refer the below help documentation link, 

Regards, 
Manivannan Padmanaban. 




AR Alexander Resnik February 4, 2020 05:16 PM UTC

The auto-generation does not work. Please can you send the working example? Thank you. Alex


GL Gowri Loganathan Syncfusion Team February 5, 2020 08:45 AM UTC

Hi Alexander, 

Query#: Working example of autogeneration columns. 
 
We have checked your query at our end and we have prepared a sample for autogenerated column. In the below sample, the columns are undefined as shown in the below code snippet. 


Kindly refer the code snippet

Aspx page 
 
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent"> 
 
           <asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
 
              <ContentTemplate> 
 
        <ej:Grid ID="OrdersGrid" runat="server" AllowPaging="True" AllowSorting="True"> 
          
                                                     // columns are undefined here 
            
        </ej:Grid> 
 
           <asp:SqlDataSource ID="SqlData" runat="server" ConnectionString="<%$ ConnectionStrings:NORTHWNDConnectionString %>" 
            SelectCommand="SELECT * FROM [Orders]"></asp:SqlDataSource> 
 
                </ContentTemplate> 
             </asp:UpdatePanel> 
         
</asp:Content> 



Please refer the below screenshot: 
 
 
Please refer the below sample and documentation: 

Please revert us if you need more assistance on this. 

Regards, 
Gowri V L. 


Loader.
Live Chat Icon For mobile
Up arrow icon