Solved

linqdatasource where bit field value = true

Posted on 2010-11-09
4
1,696 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

763 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