tags:

views:

247

answers:

2

I am using LingDataSource, and I know I can’t use join query. How/Where can I put the below SELECT STATEMENT inside the gridivew to display the DBO.TOTALHOURSLU.DISPLAY instead of the DBO.LEAVEREQUEST.TOTALHOURSEFFECT?

SELECT     dbo.LeaveRequest.TotalHoursEffect, dbo.TotalHourslu.Minutes, dbo.TotalHourslu.Display
FROM         dbo.LeaveRequest INNER JOIN
                      dbo.TotalHourslu ON dbo.LeaveRequest.TotalHoursEffect = dbo.TotalHourslu.Minutes
A: 

There are a number of things you can do:

  1. Use a SQLDataSource instead of a LinqDataSource, and put your SELECT statement into the SelectCommand property

  2. Use a LinqDataSource, and specify the TableName within your DataContext that you wish to use to populate it.

  3. Use an ObjectDataSource and bind the SelectMethod using a Linq query against your Linq to Sql data context, or use SqlAdapter and SqlConnection objects with your SELECT statement.

Robert Harvey
+1  A: 

A SqlDataSource control is probably better. You can put your SELECT statement right into the SelectCommand property of the SqlDataSource control, and then bind your SqlDataSource control to your grid control.

Here is a walkthrough:

http://msdn.microsoft.com/en-us/library/tw738475(VS.80).aspx

Robert Harvey