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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Use PivotGrid with view of sql entity

Thread ID:





143466 Mar 20,2019 08:12 PM UTC Mar 25,2019 08:45 AM UTC ASP.NET Web Forms 6
Tags: PivotGrid
Asked On March 20, 2019 08:12 PM UTC

I need to example for add dates to PivotGrid with to view of sql Entity Framework or with to DataTable. 
When is the correct option? I can use PivotGrid1.(What) for this?

Arulraj A [Syncfusion]
Replied On March 21, 2019 12:16 PM UTC

Hi Guadalupe, 

Thanks for contacting Syncfusion support. 

You can render PivotGrid with DataTable as datasource. Please follow the below steps. 

Step 1: 
Add the following class into the WebAPI controller file. 

Code Snippet:[c#] 
public class DbaseQuery 
public dynamic GetSQLResult(dynamic clientParam) 
string conSTR = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=" + AppDomain.CurrentDomain.BaseDirectory + @"App_Data\Database1.mdf;Integrated Security=True";//SQL database connection string 
string xquery = "SELECT * FROM table1"; 
SqlConnection sqlConn = new SqlConnection(conSTR); 
SqlCommand cmd = new SqlCommand(xquery, sqlConn); 
SqlDataAdapter da = new SqlDataAdapter(cmd); 
DataTable dt = new DataTable(); 
for (var i = 0; i < dt.Rows.Count; i++) 
for (var j = 0; j < dt.Rows[i].ItemArray.Length; j++) 
  dt.Rows[i].ItemArray[j] = dt.Rows[i].ItemArray[j].ToString().Trim(); 
return dt; 
Step 2:  
Call the GetSQLResult method in each method of PivotGrid WebAPI controller to feed datasource to the control.(Like, InitializeGrid, fetchMembers..etc.) 
Code Snippet:[C#] 
public Dictionary<string, object> InitializeGrid(Dictionary<string, object> jsonResult) 
htmlHelper.PivotReport = BindDefaultData(); 
dict = htmlHelper.GetJsonData(jsonResult["action"].ToString(), dbquery.GetSQLResult(null));  
return dict; 


Please let us know if you need any further assistance. 

Arulraj A 

Replied On March 21, 2019 02:33 PM UTC

I cant view the example with VisualStudio.

Replied On March 21, 2019 08:59 PM UTC

I need use pivotgrid with to view of SQL Entity Framework.
This is possible?

Arulraj A [Syncfusion]
Replied On March 22, 2019 06:53 AM UTC

Hi Guadalupe, 

Thanks for the update. 

We have provided the sample as per your requirement. The sample project can be opened using Visual Studio 2017, the project file name is “PivotDataTable.csproj”. Please check the sample and let us know if you need further assistance on this. 

Arulraj A 

Replied On March 22, 2019 12:55 PM UTC

Good morning!

I have VisualStudio 2015. Please you can reply the proyect in my version?

Thank you!

Arulraj A [Syncfusion]
Replied On March 25, 2019 08:45 AM UTC

Hi Guadalupe, 

Thanks for the update. 

As per your requirement we have prepared sample in 4.5 framework which will work in Visual Studio 2015. 

Please let us know if you have any concerns. 
Arulraj A 


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