Yves
Yves

Reputation: 12497

Using LinqDataSource with SELECT statement

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

Upvotes: 0

Views: 1299

Answers (2)

Robert Harvey
Robert Harvey

Reputation: 180787

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

Upvotes: 1

Robert Harvey
Robert Harvey

Reputation: 180787

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.

Upvotes: 0

Related Questions