ASP.net datagrid and boolean field please

  • Thread starter Thread starter Annie
  • Start date Start date
A

Annie

Hello guys,

I have a template column that is bound to a database field with True and
False value. So it displays True or False as per item.

The code is as:
<tr>
<td align="left"><b>Colour Screen</b></td>
<td><%# DataBinder.Eval(Container.DataItem, "ModelColour") %></td>
</tr>

However, i don't want to show True or False maybe display it as Yes or No or
anything customized.
How can i do it with above code?

TIA
 
Hi,

Check out the 'helper function' FAQ entry (the first one) at
http://www.idesign.net/idesign/DesktopDefault.aspx?tabindex=5&tabid=8

HTH

Hello guys,

I have a template column that is bound to a database field with True and
False value. So it displays True or False as per item.

The code is as:
<tr>
<td align="left"><b>Colour Screen</b></td>
<td><%# DataBinder.Eval(Container.DataItem, "ModelColour") %></td>
</tr>

However, i don't want to show True or False maybe display it as Yes or No or
anything customized.
How can i do it with above code?

TIA
 
<tr>
<td align="left"><b>Colour Screen</b></td>
<td><%# (DataBinder.Eval(Container.DataItem, "ModelColour") ? "Yes" :
"No")%></td>
</tr>

thats all. or maybe
<script runat="server">
private string GetBooleanString(bool val)
{
return val ? "Yes" : "No";
}
</script>

<tr>
<td align="left"><b>Colour Screen</b></td>
<td><%# GetBooleanString(DataBinder.Eval(Container.DataItem,
"ModelColour")) %></td>
</tr>
 

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

Back
Top