binding a value to a checkbox

Discussion in 'ASP .Net Web Controls' started by Esperanza, Feb 12, 2005.

  1. Esperanza

    Esperanza Guest

    Hello dotnet expert !!
    I want to present as a checkbox the values -1 as true and 0 as false stored
    in a table.
    I got a Datalist and dragged a chekbok in the ItemTemplate section.
    I link my data field to it. I compile but at execution time, I got
    "Specified cast is not valid". Where can I associate the value -1 to true
    and 0 to false ?
    I did not find it in the properties.

    Thanks for your help!!
    Esperanza

    '======================================================

    <TD><asp:CheckBox id=chkAutreSourceEnergie runat="serveur" Texte="Autre
    source energie" Checked='<# DataBinder.Eval(dataSet11,
    "Tables[Resultats].DefaultView.[0].Autre_Src_Energie")%>'>
    </asp:checkBox></TD>
    Esperanza, Feb 12, 2005
    #1
    1. Advertising

  2. You need to do something like this:

    CheckBoxItem.Checked = Convert.ToBoolean(value);

    that will convert your value(which is -1 or 0) to a boolean.




    "Esperanza" <> wrote in message
    news:%...
    > Hello dotnet expert !!
    > I want to present as a checkbox the values -1 as true and 0 as false
    > stored
    > in a table.
    > I got a Datalist and dragged a chekbok in the ItemTemplate section.
    > I link my data field to it. I compile but at execution time, I got
    > "Specified cast is not valid". Where can I associate the value -1 to true
    > and 0 to false ?
    > I did not find it in the properties.
    >
    > Thanks for your help!!
    > Esperanza
    >
    > '======================================================
    >
    > <TD><asp:CheckBox id=chkAutreSourceEnergie runat="serveur" Texte="Autre
    > source energie" Checked='<# DataBinder.Eval(dataSet11,
    > "Tables[Resultats].DefaultView.[0].Autre_Src_Energie")%>'>
    > </asp:checkBox></TD>
    >
    >
    Sean McKaharay, Feb 14, 2005
    #2
    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. tshad
    Replies:
    0
    Views:
    487
    tshad
    Apr 15, 2005
  2. Vikram

    disable checkbox list checkbox

    Vikram, Jan 25, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    1,357
    ThunderMusic
    Jan 25, 2006
  3. Imran Aziz

    checkbox value attribute in checkbox control ?

    Imran Aziz, Aug 6, 2005, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    221
    Imran Aziz
    Aug 8, 2005
  4. Vivek Nallur

    value binding and function binding

    Vivek Nallur, Sep 25, 2003, in forum: Ruby
    Replies:
    0
    Views:
    130
    Vivek Nallur
    Sep 25, 2003
  5. randy
    Replies:
    13
    Views:
    433
    Tad McClellan
    Nov 1, 2003
Loading...

Share This Page