Converting bit false to string No in Datagrid column

Discussion in 'ASP .Net Web Controls' started by stuart, Jun 9, 2004.

  1. stuart

    stuart Guest

    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
     
    stuart, Jun 9, 2004
    #1
    1. Advertising

  2. 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]

    "stuart" <> wrote in message
    news:...
    > 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
     
    Ken Cox [Microsoft MVP], Jun 10, 2004
    #2
    1. Advertising

  3. Glad to help!

    "stuart" <> wrote in message
    news:...
    > Hi Ken,
    >
    > You rock my world.....
    >
    > Both of the suggestions you gave me were spot on!
    >
    > Thanks
    >
    > "Ken Cox [Microsoft MVP]" wrote:
    >
    >> 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]
    >>
     
    Ken Cox [Microsoft MVP], Jun 10, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. André
    Replies:
    3
    Views:
    1,670
  2. Replies:
    3
    Views:
    1,854
    Timothy Bendfelt
    Jan 19, 2007
  3. Brand Bogard

    8 bit character string to 16 bit character string

    Brand Bogard, May 25, 2006, in forum: C Programming
    Replies:
    8
    Views:
    775
    those who know me have no need of my name
    May 28, 2006
  4. Replies:
    9
    Views:
    1,049
    Juha Nieminen
    Aug 22, 2007
  5. Jeff.M
    Replies:
    6
    Views:
    203
    Lasse Reichstein Nielsen
    May 4, 2009
Loading...

Share This Page