jjliu4492
asked on
How to display data from SQL Server 2008 onto a datagridview in different format
I have the following data, which I pull from a SQL Server 2008 database.
ProjectHourID TaskID WeekEndingDate ActualHours BudgetHours RemainingHours TaskName
2 1 9/30/2011 10 50 40 test 1
3 2 9/30/2011 15 100 75 test 2
4 1 9/23/2011 5 45 40 test 1
5 2 9/23/2011 10 100 90 test 2
I want to display the data above in a VS2010 windows forms application, using a datagridviewcontrol. I want to display the data in the following format on the datagridview (see screenshot). How would I do this?
Right now I am using the following code to populate the datagridview:
OperationsDataContext opDC = new OperationsDataContext();
dgTime.DataSource = opDC.Tasks_GetByProjectIDA ndWeekEndi ngDate(Con vert.ToInt 32(cboTime Project.Se lectedValu e), dtWeekEnding.Value);
dgTime.AutoResizeColumns() ;
DatagridviewFormat.png
ProjectHourID TaskID WeekEndingDate ActualHours BudgetHours RemainingHours TaskName
2 1 9/30/2011 10 50 40 test 1
3 2 9/30/2011 15 100 75 test 2
4 1 9/23/2011 5 45 40 test 1
5 2 9/23/2011 10 100 90 test 2
I want to display the data above in a VS2010 windows forms application, using a datagridviewcontrol. I want to display the data in the following format on the datagridview (see screenshot). How would I do this?
Right now I am using the following code to populate the datagridview:
OperationsDataContext opDC = new OperationsDataContext();
dgTime.DataSource = opDC.Tasks_GetByProjectIDA
dgTime.AutoResizeColumns()
DatagridviewFormat.png
I don't understand your question...what is it that you don't understand? Are you looking for formatting advice?
ASKER
I want the data from the database to look like the above screenshot when I display it in a datagridview control.
Did you define columns for the DataGridView? Did you bind the data to the DataGridView? What are you having difficulty with?
ASKER
I want the data that is pulled from the database to be displayed in a certain format within the datagridview control.
ProjectHourID TaskID WeekEndingDate ActualHours BudgetHours RemainingHours TaskName
2 1 9/30/2011 10 50 40 test 1
3 2 9/30/2011 15 100 75 test 2
4 1 9/23/2011 5 45 40 test 1
5 2 9/23/2011 10 100 90 test 2
ProjectHourID TaskID WeekEndingDate ActualHours BudgetHours RemainingHours TaskName
2 1 9/30/2011 10 50 40 test 1
3 2 9/30/2011 15 100 75 test 2
4 1 9/23/2011 5 45 40 test 1
5 2 9/23/2011 10 100 90 test 2
ASKER
OK, it seems like you want to create a cross-tab view of that data. I would suggest doing that work on the back end. What kind of data source are you working with?
ASKER
I am using linq to sql to pull the data from the database.
OperationsDataContext opDC = new OperationsDataContext();
dgTime.DataSource = null;
dgTime.DataSource = opDC.ProjectHours_GetByPro jectIDAndW eekEndingD ate(Conver t.ToInt32( cboTimePro ject.Selec tedValue), dtWeekEnding.Value);
OperationsDataContext opDC = new OperationsDataContext();
dgTime.DataSource = null;
dgTime.DataSource = opDC.ProjectHours_GetByPro
If you are working with SQL Server, on the back-end, then you could create a stored procedure to create a pivot.
ASKER
How do I create a pivot using a stored procedure?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.