views:

305

answers:

1

I'm dynamically creating a RadioButtonList and can't figure out how to add additional text to show up under the radio button.

My basic code is as follows and I want sURL to show up under each resultant radio button.

For i As Integer = 0 To ds.Tables(0).Rows.Count - 1

                Dim iLocationID As Integer = ds.Tables(0).Rows(i).Item("LocationID")
                Dim sStreet As String = ds.Tables(0).Rows(i).Item("AddressStreet")
                Dim sCity As String = ds.Tables(0).Rows(i).Item("AddressCity")
                Dim sState As String = ds.Tables(0).Rows(i).Item("AddressState")
                Dim sZip As String = ds.Tables(0).Rows(i).Item("AddressPostalCode")
                Dim sName as String = ds.Tables(0).Rows(i).Item("Name")
                Dim dsContact As New DataSet

                Dim sURL As String = ""
                sURL = "<a href='http://www.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=" & sStreet & "+" & sState & "+" & sZip & "' target='_blank'>" & sStreet & " " & sCity & " " & sState & ", " & sZip & "</a>"

                Dim dDistance As Decimal = Math.Round(ds.Tables(0).Rows(i).Item("Distance"), 1)
                Dim sDistance As String
                If dDistance > 1 Then
                    sDistance = dDistance & " Miles Away"
                Else
                    sDistance = dDistance & " Mile Away"
                End If
                sURL += " " & sDistance
                sURL += " Phone: " & sContactPhone

                rblVendorLocations.Items.Add(New ListItem(sName, iLocationID))
            Next
A: 

The first parameter to the ListItem constructor is the text to show beside the radio button, if you want that to be sURL then pass that rather than sName.

You can also pass html as this parameter if you want to style it in some particular way e.g.

ListDeliveryFrequency.Items.Add( _
              New ListItem("<div>" + sName +"</div> <div>" + sUrl + "</div>", _
                           iLocationID))
Simon Fox
I never thought about trying to add HTML. I'll give that a shot.
Mikecancook