Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Format ItemTemplate True/False as Yes/No 1

Status
Not open for further replies.

msmith425

MIS
Jan 29, 2002
15
0
0
US
I'm reading information from a database and trying to format the boolean true/false as a yes/no.

Below is the code that I came up with but this is as far as I have gotten.

<asp:DataGrid id=&quot;DataGrid2&quot; runat=&quot;server&quot; AutoGenerateColumns=&quot;False&quot;>
<Columns>
<asp:BoundColumn DataField=&quot;JobNumber&quot; HeaderText=&quot;Job Number&quot;></asp:BoundColumn>
<asp:TemplateColumn HeaderText=&quot;Complete&quot;>
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, &quot;Complete&quot;) %>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>

How do I format the True/False as a Yes/No? Or is there another way that I have not heard of?

TIA
Marc
 
Make a function in your code behind. Call it FormatBoolean(arg as object). Cast the object to a boolean and check to see what it is. Depending on the value return a string of either &quot;Yes&quot; or &quot;No&quot;. In your aspx page finish off like so.
<%# FormatBoolean(DataBinder.Eval(Container.DataItem, &quot;Complete&quot;)) %>


Twill work like a charm. A charm I say.
That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
You know, it worked like a charm. A charm I tell you.

Much Thanks.

Marc
[thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top