By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,466 Members | 1,309 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,466 IT Pros & Developers. It's quick & easy.

radiobuttonlist: omit label when .DataBind()

P: n/a
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.
Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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" <jo***@another-world.com> wrote in message
news:Xn**********************************@64.59.14 4.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.

Nov 18 '05 #2

P: n/a
"Andy Gaskell" <pubb AT hotmail DOT com> wrote in
news:eD**************@TK2MSFTNGP10.phx.gbl:
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" <jo***@another-world.com> wrote in message
news:Xn**********************************@64.59.14 4.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

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.