boolean BoundColumn

  • Thread starter Serge Lucas via .NET 247
  • Start date
S

Serge Lucas via .NET 247

Hello,

I have bound a BoundColumn to a DataGrid, which is linked to a collection whose 1rst element is a bool.

The DataGrid then displays 'true' or 'false', whereas I would like to display 'Y' or 'N' in it.

Is there a mean to avoid using a Dataset for my DataGrid ?

Thanks !
 
A

A Traveler

There are two possibilities i can think of. The first one i know will work,
because i do it all the time. The second i think should, but im not sure. As
for not using a DataSet to bind to, you can bind to any number of things,
DataSets, DataTables, Arrays, and properly defined Collections. If the
collection implements IList, then you can bind to it (there may be other
interfaces which work, i dont know). This works Very well. I have done say
an Order object, with a LineItems collection. The LineItems class implemens
IList, and then i can databind directly to the collection, with each
dataitem in the grid being an object of type LineItem.

The first would be to use the OnItemDataBound event of the grid.
Then do something like

Private Sub grid_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles grid.ItemDataBound
Dim i As DataGridItem = e.Item
Select Case i.ItemType
Case Item, AlternatingItem
i.Cells(0).Text = Iif(dr(0)=True,"Yes","No")
End Select
End Sub

or you could try in the Property builder for the grid, in the columns
section, select your column, then in the "Data Formatting Expression:" enter
something like
Iif({0}=True,"Yes","No")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Question Regarding Boolean Please 1
How to return boolean true and false 3
ItemTemplate Problem 0
Boolean 32
Bool inside switch 1
BoundColumn 1
Java 1
Runtime Error with __gcd? (floating point exception) 1

Members online

No members online now.

Forum statistics

Threads
474,143
Messages
2,570,822
Members
47,368
Latest member
michaelsmithh

Latest Threads

Top