Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > ASP.NET 4 General Discussion
|
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 22nd, 2011, 07:23 AM
Authorized User
 
Join Date: Feb 2011
Posts: 13
Thanks: 2
Thanked 0 Times in 0 Posts
Default Entity Data Source and bit data types

My project has several drop-down lists. These get filled with junk over time -- entries that used to be important but are no longer used. We don't want to delete old values because they are linked into valuable history. We don't want users to see more entries that are junk than entries that are useful. My normal solution is to add a field called "Obsolete" with a bit data type. If the field is True, the value is not shown in the drop-down.

I couldn't make this work with a where clause in an entity data source. If I use an integer type (1 = True, 0 = False), I can set the where clause to it.Obsolete = 0. But I have not found a way to make this filter work with a bit type using values True and False. What am I missing?
 
Old July 22nd, 2011, 09:51 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Dennis,

Can you post the code you're working with? Are you using C# or VB?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old July 22nd, 2011, 10:20 AM
Authorized User
 
Join Date: Feb 2011
Posts: 13
Thanks: 2
Thanked 0 Times in 0 Posts
Default

The code for an EDS is pretty simple -- I don't know if this is what you wanted. The code below works. it.obsolete is an int in the database.
Code:
    <asp:EntityDataSource ID="edsTitleName" runat="server" 
        ConnectionString="name=ETOSEntities" DefaultContainerName="ETOSEntities" 
        EnableFlattening="False" EntitySetName="Titles" Select="
it.TitleID, it.TitleName" Where="it.obsolete=0" OrderBy="it.TitleName">
    </asp:EntityDataSource>

I don't have code for the case where it.obsolete is a bit. This returned all records, whether it.obsolete was true or false

Code:
Where = "it.obsolete=False"
I also tried this. The logic is backwards, but that doesn't matter because it also failed to filter records.

Code:
Where = it.obsolete
I tried playing around with variations of these. Everything I tried returned all records, no matter whether it.obsolete was True or False. I couldn't find anything on the boards -- probably had the wrong search terms.
 
Old July 22nd, 2011, 10:29 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Is your model in sync with your database? I just created a simple test database with a required Obsolete column, and created a model. The following four options then all worked for me:

Where="it.Obsolete=False"
Where="it.Obsolete=True"
Where="it.Obsolete==False"
Where="it.Obsolete==True"

And are you using C# or VB?

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
DennisE (July 25th, 2011)
 
Old July 25th, 2011, 07:40 AM
Authorized User
 
Join Date: Feb 2011
Posts: 13
Thanks: 2
Thanked 0 Times in 0 Posts
Red face

Imar,

I can only offer my apologies. I went back and everything worked perfectly. Usually, whenever I change a data type in a table, I go to the edmx file, remove the table, then update from database and add the table again. If things don't seem to work, I usually double-check the table update. I suppose that's why I closed the mind to the possibility that this was my own silly mistake.

They say every experience is good, so long as you learn from it. That doesn't mean it's not embarassing.

BTW - I use C#.
 
Old July 25th, 2011, 02:51 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
They say every experience is good, so long as you learn from it. That doesn't mean it's not embarassing
Haha,don't worry about it. Happens to all of us..... ;-)

Glad you figured it out.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculated column for data mining data source RKevinBurton Book: Professional Microsoft SQL Server Analysis Services 2008 with MDX: 978-0-470-24798-3 0 May 4th, 2011 12:17 PM
Unable to select Entity in Data Source Configuration Wizard kuldeepty BOOK: Beginning ASP.NET 4 : in C# and VB 7 December 3rd, 2010 03:40 PM
Two data table adapter not created when using data source wizard in VS 2008 sakshismriti Visual Studio 2008 0 November 17th, 2010 01:33 AM
Data Types sophia BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 8 October 2nd, 2010 09:23 AM
Data Types edward2006 Infopath 0 November 7th, 2005 06:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.