Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6086675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:46:58+00:00 2026-05-23T11:46:58+00:00

I am relatively new to .Net and SQL Server and I need to be

  • 0

I am relatively new to .Net and SQL Server and I need to be able to do a boolean check on a DateTime datatype for a null value.

I am using the following statement which is clearly wrong as it returns an Int32 in my Visual Studio immediate window while debugging. I am using linq to call a stored procedure which interrogates a bunch of tables.

The markup that some of the result collection will be bound to look like this;

<asp:Image  ID="imgAuthorised" ImageUrl='<%# (bool)DataBinder.Eval(Container.DataItem, "AuthorisedDate")?"/Horizon/Images/save16x16.png":"/Horizon/Images/delete16x16.png" %>' runat="server" ToolTip='<%# (bool)DataBinder.Eval(Container.DataItem, "AuthorisedDate")?"Authorised":"Not Authorised" %>' />

Depending on the boolean value of the collection returned then I want to display an appropriate image. Here is my attempt(ahem) to do an evaluation within the stored proc’

CASE WHEN dbo.Expense.AuthorisedDate is null THEN 0 ELSE 1 END as AuthorisedDate

I have tried casting this statement like so;

CAST(CASE WHEN dbo.Expense.AuthorisedDate is null THEN 0 ELSE 1 END as bit) as AuthorisedDate

Feel free to giggle at any school boy errors or poor understanding as I’m a dot net newb (hence the name :P) ha!

I would appreciate if someone could help me understand what I am doing wrong and what to do/avoid in future when attempting to do stuff like this.

TIA

dotnetnewb

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T11:46:58+00:00Added an answer on May 23, 2026 at 11:46 am

    what about extending your model? Your stored procedure (lets assume it’s called GetMyData) will likely return an ISingleResult.

    If so, go to your DBML, view code (assuming this is a web application) and create a new partial class:

    public partial class GetMyDataResults
    {
        public bool IsAuthorised
        {
            get { return DateAuthorised.HasValue; }
        }
    }
    

    And then you should be able to:

    <asp:Image ID="imgAuthorised" ImageUrl='<%# DataBinder.Eval(Container.DataItem, "IsAuthorised")?"/Horizon/Images/save16x16.png":"/Horizon/Images/delete16x16.png" %>' runat="server" ToolTip='<%# DataBinder.Eval(Container.DataItem, "IsAuthorised")?"Authorised":"Not Authorised" %>' />

    Alternatively, you can piggyback onto the OnItemDataBinding event and do the work in there, though the above would be the easier path I’d think.

    Cheers,
    Terry

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm relatively new to .NET and have being using Linq2Sql for a almost a
I am doing some performance tests using .Net 3.5 against SQL Server. I am
I'm relatively new to .NET GUI programming using WinForms (the project I'm working on
I'm relatively new to VB.NET and am wondering how I can get the value
I am relatively new at using ASP.NET MVC, however I have got experience with
I'm relatively new to .NET programming (and OOP in general) and I want to
I am relatively new to .net. As I was trying to grasp the concept
Being relatively new to the .net game, I was wondering, has anyone had any
I'm relatively new to ASP.NET and was wondering if anyone could shed some light
I am relatively new to ASP.NET MVC, and am very impressed with the clarity

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.