Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > radiobuttonlist: omit label when .DataBind()

Reply
Thread Tools

radiobuttonlist: omit label when .DataBind()

 
 
hellrazor
Guest
Posts: n/a
 
      05-16-2004
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.
 
Reply With Quote
 
 
 
 
Andy Gaskell
Guest
Posts: n/a
 
      05-17-2004
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" <(E-Mail Removed)> wrote in message
news:Xns94EB83BDA85F9jorgeanotherworldcom@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.



 
Reply With Quote
 
 
 
 
hellrazor
Guest
Posts: n/a
 
      05-17-2004
"Andy Gaskell" <pubb AT hotmail DOT com> wrote in
news:(E-Mail Removed):

> 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" <(E-Mail Removed)> wrote in message
> news:Xns94EB83BDA85F9jorgeanotherworldcom@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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Totally omit default parameter brackets from template? tony@donotspamme.ar C++ 1 08-24-2006 06:27 PM
Totally omit default parameter brackets from template? tony@donotspamme.ar C++ 2 08-24-2006 05:10 PM
We could omit curly brackets in function declaration? STF C++ 6 06-24-2005 02:14 PM
Please illustrate how to omit null field from a DB using a datalist. Troy ASP .Net 1 08-26-2003 07:03 PM
How to omit a header? RB C Programming 1 07-01-2003 04:26 PM



Advertisments