I am converting the Rows as Columns using PIVOT in SQL Server. Keeping the result set in a DataTable
and binding the DataTable
with a GridView
. As I want to generate the Column Dynamically based on the Rows, I am using PIVOT operation. How do I proceed if i don't want to use DataTable
and want to use a ViewModel
in place of DataTable?
Asked
Active
Viewed 289 times
0

Waqar Janjua
- 6,113
- 2
- 26
- 36

Rajkumar Vasan
- 712
- 1
- 9
- 22
-
what do you mean by ViewModel ? – Waqar Janjua Jul 14 '12 at 07:52
-
@Waqar, ViewModel is nothing but a view specific Model object. For example you can keep a DataSet or DataTable as a DataSource for a GridView in a View. Here you can replace DataTable or DataSet using Collection of ViewModel. – Rajkumar Vasan Jul 14 '12 at 07:57
-
sorry freind I'm unable to understand you question. – Waqar Janjua Jul 14 '12 at 08:06
1 Answers
1
I've asked this question before but for winforms. I too had to pivot sql data. The answer was to make use of System.ComponentModel
.
See top answer here: Data binding dynamic data

Community
- 1
- 1

Chris Moutray
- 18,029
- 7
- 45
- 66
-
1Looks like I am not alone...Thanks..will accept the answer after going through the complete instructions. – Rajkumar Vasan Jul 14 '12 at 08:22