Converting bit false to string No in Datagrid column

S

stuart

Hi there

I have a dataset bound to a datagrid and the dataset/datagrid has a column bound to a bit field in a sql server database
The problem I'm having is the datagrid is displaying 'True' and 'False', where I want it to display 'Yes' and 'No'. How can I do this?
If this is not possible, how do I bind this column to a list of checkbox controls within the datagrid

Cheers
 
K

Ken Cox [Microsoft MVP]

Hi Stuart,

You might be able to change the text in the label like this:

<asp:TemplateColumn HeaderText="Boolean Value">
<ItemTemplate>
<asp:Label id="Label1" runat="server"><%#
IIF(DataBinder.Eval(Container, "DataItem.Boolean"),"Yes","No")
%></asp:Label>
</ItemTemplate>
</asp:TemplateColumn>

Does this help?

Ken
Microsoft MVP [ASP.NET]
 
K

Ken Cox [Microsoft MVP]

Glad to help!

stuart said:
Hi Ken,

You rock my world.....

Both of the suggestions you gave me were spot on!

Thanks

Ken Cox said:
Hi Stuart,

You might be able to change the text in the label like this:

<asp:TemplateColumn HeaderText="Boolean Value">
<ItemTemplate>
<asp:Label id="Label1" runat="server"><%#
IIF(DataBinder.Eval(Container, "DataItem.Boolean"),"Yes","No")
%></asp:Label>
</ItemTemplate>
</asp:TemplateColumn>

Does this help?

Ken
Microsoft MVP [ASP.NET]
 

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

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top