Convert a Checkbox value to text in a Formview item template

Discussion in 'ASP .Net Web Controls' started by gadya, Aug 9, 2006.

  1. gadya

    gadya Guest

    In an Item template in a formview I have a checkbox thus:

    parking:
    <asp:CheckBox ID="parkingCheckBox" runat="server" Checked='<%#
    eval("parking") %>'
    Enabled="false" / >

    However I don't want to display "parking" followed by a ticked/unticked box
    but rather to display "parking" (in a label?) if the check box is ticked, and
    not to display anything if it is unticked. How can I do this?

    --
    Victor
     
    gadya, Aug 9, 2006
    #1
    1. Advertising

  2. gadya wrote:
    > In an Item template in a formview I have a checkbox thus:
    >
    > parking:
    > <asp:CheckBox ID="parkingCheckBox" runat="server" Checked='<%#
    > eval("parking") %>'
    > Enabled="false" / >
    >
    > However I don't want to display "parking" followed by a ticked/unticked box
    > but rather to display "parking" (in a label?) if the check box is ticked, and
    > not to display anything if it is unticked. How can I do this?


    Maybe setup something like (in C#):
    ....
    <ItemTemplate>
    <%# Eval("parking").ToString() == "1" : "parking" ? String.Empty %>
    </ItemTemplate>
    ....

    At least that's how I've done it with a DataGrid.
     
    Dan Christensen, Aug 9, 2006
    #2
    1. Advertising

  3. gadya

    gadya Guest

    Thanks a lot. I was surprised to find that the ternary operator did not exist
    in vb.net and in VB the result looks like this:

    <%#IIf(Eval("parking") = "true", "parking </br>", String.Empty)%>

    --
    Victor


    "Dan Christensen" wrote:

    > gadya wrote:
    > > In an Item template in a formview I have a checkbox thus:
    > >
    > > parking:
    > > <asp:CheckBox ID="parkingCheckBox" runat="server" Checked='<%#
    > > eval("parking") %>'
    > > Enabled="false" / >
    > >
    > > However I don't want to display "parking" followed by a ticked/unticked box
    > > but rather to display "parking" (in a label?) if the check box is ticked, and
    > > not to display anything if it is unticked. How can I do this?

    >
    > Maybe setup something like (in C#):
    > ....
    > <ItemTemplate>
    > <%# Eval("parking").ToString() == "1" : "parking" ? String.Empty %>
    > </ItemTemplate>
    > ....
    >
    > At least that's how I've done it with a DataGrid.
    >
    >
     
    gadya, Aug 10, 2006
    #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. ABHIJIT B
    Replies:
    2
    Views:
    2,337
    ABHIJIT B
    Feb 5, 2008
  2. Vannela

    Hoe to get DataList Checkbox status in item template

    Vannela, Dec 16, 2003, in forum: ASP .Net Building Controls
    Replies:
    4
    Views:
    241
    Vannela
    Dec 29, 2003
  3. QUASAR
    Replies:
    6
    Views:
    435
    QUASAR
    Jan 17, 2004
  4. Imran Aziz

    checkbox value attribute in checkbox control ?

    Imran Aziz, Aug 6, 2005, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    234
    Imran Aziz
    Aug 8, 2005
  5. randy
    Replies:
    13
    Views:
    461
    Tad McClellan
    Nov 1, 2003
Loading...

Share This Page