LinqDataSource Where Parameters

Hi EE,

I have a list view that is bound to a table.  
In code I have been able to select a foreign table from the linq to sql but do not know how to do using the datasource control.

i.e. The table I am bound to is linked to other tables.  In code I would do something like
Dim q = (From p in dc.Table1 select p).firstordefault

Then I could get the other tables values through q

q.table2.ValueToGet

How do I write a where parameter using linqdatasource control?

Currently I get the error... The name for parameter 'ProductDetail.NotSold' on LinqDataSource 'lnqProdSold' is not a valid identifier name.

Thanks  (Hope this is clear)
<asp:LinqDataSource ID="lnqProdSold" runat="server" 
                     ContextTypeName="Service2020.SalonDataClassesDataContext" EnableDelete="True" 
                     EnableInsert="True" EnableUpdate="True" TableName="ProductsSoldUseds" 
                     Where="ServiceID == @ServiceID &amp;&amp; ProductDetail.NotSold == False">
                     <WhereParameters>
                         <asp:ControlParameter ControlID="txtServiceID" Name="ServiceID" 
                             PropertyName="Text" Type="Int32" />
                         <asp:Parameter DefaultValue="False" Name="ProductDetail.NotSold" Type="Boolean" />
                     </WhereParameters>
                 </asp:LinqDataSource>

Open in new window

SheritlwAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MlandaTCommented:
Have a look at this page http://msdn.microsoft.com/en-us/library/bb470363.aspx. Pay attention to the  section on "Selecting Values from Related Tables".

In order to access data in related tables, the key thing is that you need to "customise" the select statement. That section gives you a nice example how to go about it. Could help further, with a more specific code example, but have no idea what you have in your tables.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.