radiobuttonlist: omit label when .DataBind()

Discussion in 'ASP .Net' started by hellrazor, May 16, 2004.

  1. hellrazor

    hellrazor Guest

    Hi there,

    I'm successfully streaming a list of items into a radiobuttonlist. I am
    using an ArrayList as a data source, which I have built from a table of
    values in a MySQL table. It's working great. My only issue is that it is
    printing the label along the rendering of the radio objects. How do I
    keep the radiobuttonlist object from displaying the labels?

    So for example, I've got the following ArrayList:

    arrayList1 = New ArrayList
    arrayList1.Add("one")
    arrayList1.Add("two")
    arrayList1.Add("three")


    radiobuttonlist1.DataSource = arrayList1
    radiobuttonlist1.DataBind

    In the HTML page, the following is displayed:

    o One
    o Two
    o Three

    I want to just display:

    o
    o
    o

    And maybe have the label text actually be the value of each radio object.

    Any suggestions?

    Thanks in advance.
    hellrazor, May 16, 2004
    #1
    1. Advertising

  2. hellrazor

    Andy Gaskell Guest

    Here's what I ended up doing to make the text empty:

    1. Create a class to hold the string

    Public Class RadioListItem

    Private s As String

    Public Property MyString() As String
    Get
    MyString = s
    End Get
    Set(ByVal Value As String)
    s = Value
    End Set
    End Property

    Public ReadOnly Property EmptyString() As String
    Get
    EmptyString = String.Empty
    End Get
    End Property

    End Class

    2. Change the code in the page slightly
    Dim item1 As New RadioListItem
    item1.MyString = "One"

    Dim item2 As New RadioListItem
    item2.MyString = "Two"

    Dim item3 As New RadioListItem
    item3.MyString = "Three"


    Dim al As New ArrayList
    al.Add(item1)
    al.Add(item2)
    al.Add(item3)

    RadioButtonList1.DataSource = al
    RadioButtonList1.DataTextField = "EmptyString"
    RadioButtonList1.DataBind()

    I'm a little unclear on what "And maybe have the label text actually be the
    value of each radio object." means. If you can give an example of what
    you're looking for I'll try to help you out.

    "hellrazor" <> wrote in message
    news:Xns94EB83BDA85F9jorgeanotherworldcom@64.59.144.76...
    > Hi there,
    >
    > I'm successfully streaming a list of items into a radiobuttonlist. I am
    > using an ArrayList as a data source, which I have built from a table of
    > values in a MySQL table. It's working great. My only issue is that it is
    > printing the label along the rendering of the radio objects. How do I
    > keep the radiobuttonlist object from displaying the labels?
    >
    > So for example, I've got the following ArrayList:
    >
    > arrayList1 = New ArrayList
    > arrayList1.Add("one")
    > arrayList1.Add("two")
    > arrayList1.Add("three")
    >
    >
    > radiobuttonlist1.DataSource = arrayList1
    > radiobuttonlist1.DataBind
    >
    > In the HTML page, the following is displayed:
    >
    > o One
    > o Two
    > o Three
    >
    > I want to just display:
    >
    > o
    > o
    > o
    >
    > And maybe have the label text actually be the value of each radio object.
    >
    > Any suggestions?
    >
    > Thanks in advance.
    Andy Gaskell, May 17, 2004
    #2
    1. Advertising

  3. hellrazor

    hellrazor Guest

    "Andy Gaskell" <pubb AT hotmail DOT com> wrote in
    news::

    > Here's what I ended up doing to make the text empty:
    >
    > 1. Create a class to hold the string
    >
    > Public Class RadioListItem
    >
    > Private s As String
    >
    > Public Property MyString() As String
    > Get
    > MyString = s
    > End Get
    > Set(ByVal Value As String)
    > s = Value
    > End Set
    > End Property
    >
    > Public ReadOnly Property EmptyString() As String
    > Get
    > EmptyString = String.Empty
    > End Get
    > End Property
    >
    > End Class
    >
    > 2. Change the code in the page slightly
    > Dim item1 As New RadioListItem
    > item1.MyString = "One"
    >
    > Dim item2 As New RadioListItem
    > item2.MyString = "Two"
    >
    > Dim item3 As New RadioListItem
    > item3.MyString = "Three"
    >
    >
    > Dim al As New ArrayList
    > al.Add(item1)
    > al.Add(item2)
    > al.Add(item3)
    >
    > RadioButtonList1.DataSource = al
    > RadioButtonList1.DataTextField = "EmptyString"
    > RadioButtonList1.DataBind()
    >
    > I'm a little unclear on what "And maybe have the label text actually
    > be the value of each radio object." means. If you can give an example
    > of what you're looking for I'll try to help you out.
    >
    > "hellrazor" <> wrote in message
    > news:Xns94EB83BDA85F9jorgeanotherworldcom@64.59.144.76...
    >> Hi there,
    >>
    >> I'm successfully streaming a list of items into a radiobuttonlist. I
    >> am using an ArrayList as a data source, which I have built from a
    >> table of values in a MySQL table. It's working great. My only issue
    >> is that it is printing the label along the rendering of the radio
    >> objects. How do I keep the radiobuttonlist object from displaying the
    >> labels?
    >>
    >> So for example, I've got the following ArrayList:
    >>
    >> arrayList1 = New ArrayList
    >> arrayList1.Add("one")
    >> arrayList1.Add("two")
    >> arrayList1.Add("three")
    >>
    >>
    >> radiobuttonlist1.DataSource = arrayList1
    >> radiobuttonlist1.DataBind
    >>
    >> In the HTML page, the following is displayed:
    >>
    >> o One
    >> o Two
    >> o Three
    >>
    >> I want to just display:
    >>
    >> o
    >> o
    >> o
    >>
    >> And maybe have the label text actually be the value of each radio
    >> object.
    >>
    >> Any suggestions?
    >>
    >> Thanks in advance.

    >
    >
    >


    Thanks for the reply,

    I ended up adding each radio item manually... well, iterating through the
    array:

    travelModesArrayListValues = a flat array holding each value I need to
    stream out as radio buttons.



    If Not Page.IsPostBack Then

    For i = 0 To travelModesArrayListValues.Count - 1
    radioButtonListObj.Items.Add(New ListItem("", _
    travelModesArrayListValues.Item(i)))
    Next i

    End If
    hellrazor, May 17, 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. Troy
    Replies:
    1
    Views:
    341
    S. Justin Gengo
    Aug 26, 2003
  2. RB

    How to omit a header?

    RB, Jul 1, 2003, in forum: C Programming
    Replies:
    1
    Views:
    689
    Thomas Matthews
    Jul 1, 2003
  3. STF
    Replies:
    6
    Views:
    439
  4. Michael
    Replies:
    0
    Views:
    210
    Michael
    Dec 29, 2003
  5. Knut Krueger
    Replies:
    8
    Views:
    245
    Knut Krueger
    Aug 20, 2013
Loading...

Share This Page