[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1758
  • Last Modified:

linqdatasource where bit field value = true

Hi EE.

I have a dropdownlist bound to a linqdatasource.   The table it is bound to has a bit field.
I simply want to filter the linqdatasource by this field.
i.e. where bitfield = true

How do I do this?

Thanks
0
Sheritlw
Asked:
Sheritlw
  • 3
1 Solution
 
SheritlwAuthor Commented:
I love those articles and that is where I have got most of my information.
Problem is with the boolean value I get an error regarding the == not being int32.

I need to know how to filter by a boolean value.

Thanks


<asp:LinqDataSource ID="LnqLUServicesPrimary" runat="server" 
                                       ContextTypeName="SalonDataClassesDataContext" TableName="ServicesLUs" 
                                       Where="MultiServ == @MultiServ">
                                      <WhereParameters>
                                            <asp:Parameter Name="MultiServ" Type="Boolean" DefaultValue="true" />
                                       
                                      </WhereParameters>
                                  </asp:LinqDataSource>

Open in new window

0
 
SheritlwAuthor Commented:
I figured it out.
If values in the field are null then you will receive an exception similar to Operator '==' incompatible with operand types 'Boolean?' and 'Int32'.

Since I added the field when there was already data in the table, the field held null values.  Once I edited the table, I changed the aspx to the code below... and it works!


<asp:LinqDataSource ID="LnqLUServicesPrimary" runat="server" 
                                       ContextTypeName="SalonDataClassesDataContext" TableName="ServicesLUs" 
                                       Where="MultiServ == True">
                                      <WhereParameters>
                                            <asp:Parameter Name="MultiServ" Type="Boolean" DefaultValue="true" />
                                       
                                      </WhereParameters>
                                  </asp:LinqDataSource>

Open in new window

0
 
SheritlwAuthor Commented:
Found answer
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now