Need help binding RadioButtonList

binici

Active member
Joined
Sep 11, 2006
Messages
26
Programming Experience
Beginner
Hello all:
I am trying to have an array of images in a RadioButtonList, which is working, but I need to set the values (Image file names) to each item within the RadioButtonList, but I am having some difficulties.
I have this so far:
ASPX:
<
asp:RadioButtonList ID="radiolist1" runat="server" AutoPostBack="true" CellPadding="4" CellSpacing="0" RepeatDirection="Horizontal" RepeatLayout="Table"></asp:RadioButtonList> VB:
Const
IMAGE_DIRECTORY As String = "/homepage/Images/Articles/"
Dim pics As ArrayList = New ArrayList()
Dim s As String, html As String
Dim value As String
For Each s In Directory.GetFiles(Server.MapPath(IMAGE_DIRECTORY), "*.jpg") html =
"<img width=50 height=50 src=""" & IMAGE_DIRECTORY & Path.GetFileName(s) & """>" value = Path.GetFileName(s)
pics.Add(html)

Next radiolist1.DataSource = pics
radiolist1.DataBind()
radiolist1.Items.Item(0).Value = value
I have that in the Sub Page_Load.
When I set the RadioButtonList with the
SelectedIndexChanged event, I get an error message:

A potentially dangerous Request.Form value was detected from the client (radiolist1="<img width=50 height...").

How can I set the value for each RadioButtonList with the file name?
 

binici

Active member
Joined
Sep 11, 2006
Messages
26
Programming Experience
Beginner
If (Not Page.IsPostBack) Then
Const IMAGE_DIRECTORY As String = "/homepage/Images/Articles/"
'Dim pics As ArrayList = New ArrayList()
Dim s As String, html As String
Dim value As String
For Each s In Directory.GetFiles(Server.MapPath(IMAGE_DIRECTORY), "*.jpg")
html =
"<img width=50 height=50 src=""" & IMAGE_DIRECTORY & Path.GetFileName(s) & """>"
value = Path.GetFileName(s)
radiolist1.Items.Add(
New ListItem(html, value))
'pics.Add(html)
Next
End If
'radiolist1.DataSource = pics
'radiolist1.DataBind()
 
Top Bottom