linqdatasource where bit field value = true

Posted on 2010-11-09
Last Modified: 2012-05-10
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?

Question by:Sheritlw
  • 3

Expert Comment

ID: 34099222

Author Comment

ID: 34099259
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.


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

Open in new window


Accepted Solution

Sheritlw earned 0 total points
ID: 34099349
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">
                                            <asp:Parameter Name="MultiServ" Type="Boolean" DefaultValue="true" />

Open in new window


Author Closing Comment

ID: 34130324
Found answer

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SSRS ReportViewer report timeout 7 122
Error in query expression 3 42
How do I prevent the pages in my site from showing up in a google search? 2 72
jquery progress bar 3 40
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now