[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2309
  • Last Modified:

DataFormatString in datagrid - {0:???} change 'true' 'false' to 'T' 'F' in display

Hello All,

When using a .net datagrid or grid view , does anyone know the
syntaxt that would change a bound field that is recieved as true/false
to display as T and F when the datagrid displays.

I'm really trying to display True/False as  "A" for Active or "I" for Inactive

thank You
1 Solution
I do not think you can do that using dataformatstring.

For a asp.net 2.0 gridview you could use a templatefield for your field, if it is boolean the ItemTemplate  will be like
<asp:Label ID="Label1" runat="server" Text='<%# (bool)Eval("YourBoolField")?"A":"I" %>'></asp:Label>

The syntax in an asp.net 1 will be something like DataBinder.Eval(Container.DataItem,"YourBoolField").ToString()=="True"?"A":"I"

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now