Advertisement

06.06.2005 at 07:34AM PDT, ID: 21448130
[x]
Attachment Details

Best way to handle dynamic datagrid columns from a pivot table.

Asked by acadalzo in Programming for ASP.NET

Tags: datagrid, dynamic, pivot, columns

I want to display the results of a pivot table in a datagrid.  I have defined the static columns in the <Columns> section as bound columns.  Since I don't know what the pivoted columns are going to be (they are data dependent) I have to dynamically add them in the code before doing the data binding.  That works ok, but on postback is where it gets ugly.  What I have to do in the Page_Init is recreate the dynamic columns because they won't be preserved in the postback.  Unless they are  recreated in the Page_Init event, the sort event will not fire when the header of one of the "pivot" (i.e. dynamic) columns is clicked.  This means I have to save those column names in a Session variable, so I know what I need to recreate on the postback.  That handles the problem with sorting on a pivot column.  If instead of doing a sort, the user changes any of the criteria, I get the new set of data and I transform it into a new pivot table.  Now I have to delete all of the pivot columns in the datagrid from the previous request.    It seems that there are a whole lot of issues to deal with for dynamically-created columns.  Is there an easier way?  Am I missing something here?  Thanks.Start Free Trial
 
Loading Advertisement...
 
[+][-]06.06.2005 at 07:50AM PDT, ID: 14153685

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.06.2005 at 07:58AM PDT, ID: 14153763

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.06.2005 at 09:30AM PDT, ID: 14154770

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.08.2005 at 01:51PM PDT, ID: 14174584

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.22.2005 at 12:39AM PDT, ID: 14273131

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Programming for ASP.NET
Tags: datagrid, dynamic, pivot, columns
Sign Up Now!
Solution Provided By: shivam2k
Participating Experts: 3
Solution Grade: A
 
 
[+][-]07.01.2005 at 08:41AM PDT, ID: 14348815

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.01.2005 at 08:18PM PDT, ID: 14352575

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32