Solved

linqdatasource where bit field value = true

Posted on 2010-11-09
4
1,686 Views
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?

Thanks
0
Comment
Question by:Sheritlw
  • 3
4 Comments
 
LVL 4

Expert Comment

by:ValleyENT
ID: 34099222
0
 

Author Comment

by:Sheritlw
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.

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
 

Accepted Solution

by:
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">

                                      <WhereParameters>

                                            <asp:Parameter Name="MultiServ" Type="Boolean" DefaultValue="true" />

                                       

                                      </WhereParameters>

                                  </asp:LinqDataSource>

Open in new window

0
 

Author Closing Comment

by:Sheritlw
ID: 34130324
Found answer
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
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.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 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

22 Experts available now in Live!

Get 1:1 Help Now