Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Mar 2006
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need help binding RadioButtonList

    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?

  • #2
    New Coder
    Join Date
    Mar 2006
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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()


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •