Solved

linqdatasource where bit field value = true

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 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

19 Experts available now in Live!

Get 1:1 Help Now