Need to display bit column in DataGrid as '*' if true. SQL Server 2005 Visual Studio 2005

Posted on 2007-09-30
Last Modified: 2013-11-26
Need to display bit column in DataGrid as '*' if true.

I have a read only bound field whos value will be true or false.
If the value is True, I need to display an asterisk (*), otherwise display a blank.
<asp:BoundField DataField="Purchased" HeaderText="P" ReadOnly="True" SortExpression="Purchased" />

How can I do this in the DataGrid properties?

If not, how can I do this in the SQL Statement?

Question by:Dovberman
    LVL 142

    Accepted Solution

    I would do that in the query:

    select case when yourbitfield = 1 then '*' else '' end as yourbitfield

    Author Comment

    Could a template column of the datagrid also be used?

    Author Comment

    SELECT *,
    (select case when purchased = 1 then '*'
    else '' end) as Buy FROM watchlist

    Your suggestion worked well.


    Author Comment


    Worked in SQL Server but not in Net.ASP

    Works in SQL Server 2005 but not in ASP.NET

    SelectCommand="SELECT WatchListID,Symbol.SecName,Symbol.SymbolName,
            WatchList.SymbolID,Market.MarketName, CONVERT(VARCHAR,(PickDate),1)AS PickDate,
            CAST(PickDatePrice AS Decimal(5,2)) AS PickDatePrice,
            CAST(RecentPrice AS Decimal(5,2)) AS RecentPrice,
            CAST((RecentPrice-PickDatePrice)AS Decimal(5,2)) AS Diff,
            CAST(((RecentPrice-PickDatePrice)/PickDatePrice) * 100 AS Decimal(3,1))  
            As PctChg,DATEDIFF (day ,PickDate, RecentTradeDate) As PickDays,
            (select case when purchased = 1 then '*'
          else '' end) as Buy FROM watchlist

    <asp:BoundField DataField="B" HeaderText="B" />


    A field or property with the name 'B' was not found on the selected data source.

    LVL 142

    Expert Comment

    by:Guy Hengel [angelIII / a3]
    I just posted in the question you created meanwhile, before you posted here also...
    I guess it's just a typo ...

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    779 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

    14 Experts available now in Live!

    Get 1:1 Help Now