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?
 
MlandaTConnect With a Mentor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.