Data Bound Controls

Discussion in 'ASP .Net Web Controls' started by Karen A Hodge, Jun 12, 2004.

  1. I have a RadioButtonList on my form. There are only two items in the
    collection, "No" = 0, and "Yes" = 1. I have the SelectedIndex property bound
    to a SQL Server table which has a column of datatype, bit. The default value
    is zero for that column. I expect that after the databinding occurs, any
    value of 1 would have "Yes" selected and that 0 would have "No" selected,
    instead, neither are selected as if the selected index were -1.
    What am I doing wrong?
    Thanks in advance for the help
     
    Karen A Hodge, Jun 12, 2004
    #1
    1. Advertising

  2. Karen A Hodge

    ranganh Guest

    Dear Karen,

    After you do the DataBind, set the default value as 0 or 1 dependign upon your requirement.

    RadioButtonList.SelectedIndex = 0; (or 1 if you want 1 to be selected as default)

    that will ensure the radiobutton list is not left unchecked.

    one suggestion, if there are only 2 values, you dont need a radiobuttonlist, you can very well go for the radiobutton and set the default property by allowing checked=true

    hope it helps.



    "Karen A Hodge" wrote:

    > I have a RadioButtonList on my form. There are only two items in the
    > collection, "No" = 0, and "Yes" = 1. I have the SelectedIndex property bound
    > to a SQL Server table which has a column of datatype, bit. The default value
    > is zero for that column. I expect that after the databinding occurs, any
    > value of 1 would have "Yes" selected and that 0 would have "No" selected,
    > instead, neither are selected as if the selected index were -1.
    > What am I doing wrong?
    > Thanks in advance for the help
    >
    >
    >
     
    ranganh, Jun 12, 2004
    #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. Josh
    Replies:
    1
    Views:
    554
    ashish
    Mar 23, 2005
  2. sunil panda

    Lower bound & Upper bound

    sunil panda, Dec 25, 2003, in forum: Java
    Replies:
    9
    Views:
    7,354
    thushara wijeratna
    Oct 7, 2008
  3. Rhiner Dan
    Replies:
    1
    Views:
    773
    Mike Wahler
    Mar 27, 2005
  4. Mario Krsnic
    Replies:
    0
    Views:
    398
    Mario Krsnic
    Jun 23, 2006
  5. Phillip Vong
    Replies:
    0
    Views:
    433
    Phillip Vong
    Jul 27, 2006
Loading...

Share This Page