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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Autogenerate Columns From SQL Server Stored Procedure

Thread ID:

Created:

Updated:

Platform:

Replies:

144807 May 23,2019 02:30 PM UTC Feb 5,2020 08:45 AM UTC ASP.NET Web Forms 3
loading
Tags: Grid
Alex Jermy
Asked On May 23, 2019 02:30 PM UTC

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

Manivannan Padmanaban [Syncfusion]
Replied On 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. 



Alexander Resnik
Replied On February 4, 2020 05:16 PM UTC

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

Gowri Loganathan [Syncfusion]
Replied On 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. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon