473,406 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Format how a field is displayed in grid

In my code behind I add a coloumn to a datgrid :

Expand|Select|Wrap|Line Numbers
  1. lBlockUsedUp.DataField = "BlockUsedUp"
Expand|Select|Wrap|Line Numbers
  1. lBlockUsedUp.HeaderText = "Blocks Used Up"
Expand|Select|Wrap|Line Numbers
  1. lBlockUsedUp.ItemStyle.Width = New Unit(300)
Expand|Select|Wrap|Line Numbers
  1.  dgBiopsyLocation.Columns.Add(lBlockUsedUp)
I then bind in code with :

Expand|Select|Wrap|Line Numbers
  1.  dgBiopsyLocation.DataSource = iDataset.Tables
  2. ("ArrBiopsyLocation")
Expand|Select|Wrap|Line Numbers
  1. dgBiopsyLocation.DataBind()
The problem I am having is that the field "BlockUsedUp",
which is a bit field in SQL SERVER always shows "FALSE"
when the value = 0. I want this to be "" if it is 0 and I
want to do it all in my code behind.

Can anyone help ?
Nov 18 '05 #1
2 792
If it is an option you can try to do this in the SQL statement

Something like:

SELECT
col1,
CASE col2
WHEN 1 THEN 'True'
ELSE ''
END AS newCol2
FROM
myTable

/mortb

"Poppy" <an*******@discussions.microsoft.com> wrote in message
news:23*****************************@phx.gbl...
In my code behind I add a coloumn to a datgrid :

Expand|Select|Wrap|Line Numbers
  1. lBlockUsedUp.DataField = "BlockUsedUp"
Expand|Select|Wrap|Line Numbers
  1. lBlockUsedUp.HeaderText = "Blocks Used Up"
Expand|Select|Wrap|Line Numbers
  1. lBlockUsedUp.ItemStyle.Width = New Unit(300)
Expand|Select|Wrap|Line Numbers
  1.  dgBiopsyLocation.Columns.Add(lBlockUsedUp)

I then bind in code with :

Expand|Select|Wrap|Line Numbers
  1.  dgBiopsyLocation.DataSource = iDataset.Tables
  2.  ("ArrBiopsyLocation")
Expand|Select|Wrap|Line Numbers
  1. dgBiopsyLocation.DataBind()

The problem I am having is that the field "BlockUsedUp",
which is a bit field in SQL SERVER always shows "FALSE"
when the value = 0. I want this to be "" if it is 0 and I
want to do it all in my code behind.

Can anyone help ?

Nov 18 '05 #2
"Poppy" <an*******@discussions.microsoft.com> wrote in message
news:23*****************************@phx.gbl...
In my code behind I add a coloumn to a datgrid :

Expand|Select|Wrap|Line Numbers
  1. lBlockUsedUp.DataField = "BlockUsedUp"
Expand|Select|Wrap|Line Numbers
  1. lBlockUsedUp.HeaderText = "Blocks Used Up"
Expand|Select|Wrap|Line Numbers
  1. lBlockUsedUp.ItemStyle.Width = New Unit(300)
Expand|Select|Wrap|Line Numbers
  1.  dgBiopsyLocation.Columns.Add(lBlockUsedUp)

I then bind in code with :

Expand|Select|Wrap|Line Numbers
  1.  dgBiopsyLocation.DataSource = iDataset.Tables
  2.  ("ArrBiopsyLocation")
Expand|Select|Wrap|Line Numbers
  1. dgBiopsyLocation.DataBind()

The problem I am having is that the field "BlockUsedUp",
which is a bit field in SQL SERVER always shows "FALSE"
when the value = 0. I want this to be "" if it is 0 and I
want to do it all in my code behind.

Can anyone help ?


What kind of column is it? A BoundColumn? You may need to use a
TemplateColumn.

bit(1) in SQL is translated to bool in .NET.
--
John Saunders
johnwsaundersiii at hotmail
Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: ehm | last post by:
I am working on creating an editable grid (for use in adding, deleting, and editing rows back to an Oracle database). I have a JSP that posts back to a servlet, which in turns posts to a WebLogic...
13
by: Aladdin | last post by:
I have an MS Access form on which I have a listbox listing tables in that database. I want to be able to click on any of those tables and view its contents on the same form using subforms or any...
2
by: Betrock | last post by:
This is probably very simple, but I just can't see my way thru it..... Short version: keyed values(numeric)in a lookup table are stored in a main table. They are displayed as text values - the...
3
by: John young | last post by:
I have been looking for an answer to a problem and have found this group and hope you can assist . I have been re doing a data base I have made for a car club I am with and have been trying to...
2
by: Jim Heavey | last post by:
Hello, I have a datagrid which is bound to a datatable. I created the "DataGridTableStyle" object and defined all of the columns that I wanted to display. There was one column, however that I did...
1
by: Julius Fenata | last post by:
Dear all, I need help to change my item-template value format... Here is my case, I have a datagrid, with 'SubjectPrice' field, and when the grid displayed, my 'SubjectPrice' field displayed...
5
by: Robin Tucker | last post by:
My database has a column for numeric data items. How can I use this number in the "format" command, such that for, say precision 2, I get numbers like 2011.01 or 2387.00 and for 4 I would get...
1
by: =?Utf-8?B?QmVu?= | last post by:
I've a date field displayed at a DataGridView, and want to format it to 'yyyymmdd hh:mm:ss'. How would you do that? Thanks, Ben
3
by: harry.viet | last post by:
I use the prototype library and create a class that builds a grid using some parameters as mentioned below. Everything is working but only the parameters for Number formatting var gridopts = {...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.