• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 209
  • Last Modified:

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

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?

Thanks,
0
Dovberman
Asked:
Dovberman
  • 3
  • 2
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
I would do that in the query:

select case when yourbitfield = 1 then '*' else '' end as yourbitfield
 ...
0
 
DovbermanAuthor Commented:
Could a template column of the datagrid also be used?
0
 
DovbermanAuthor Commented:
SELECT *,
(select case when purchased = 1 then '*'
else '' end) as Buy FROM watchlist

Your suggestion worked well.

Thanks,
0
 
DovbermanAuthor Commented:
Opps,

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" />

Error:

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

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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now