Retrieving selected value from RadioBottonList
Posted on 2007-07-24
I have an ASP.NET 2.0 RadioBottonList that is being populated with 1 blank entry and the directory listing of an image folder.
<asp:RadioButtonList ID="rblLogo" runat="server" />
Const IMAGE_DIRECTORY As String = "../Images/Subscribers/"
Dim s As String, html As String
Dim value As String
rblLogo.Items.Add(New ListItem("None", ""))
For Each s In Directory.GetFiles(Server.MapPath(IMAGE_DIRECTORY), "*.gif")
html = "<img src=""" & IMAGE_DIRECTORY & Path.GetFileName(s) & """>"
value = Path.GetFileName(s)
rblLogo.Items.Add(New ListItem(html, value))
In a MySQL database I have a `Logo` column that stores the name of of file: "name.gif". When reading from the database I can select the correct image in the RadioButtonList with
rblLogo.SelectedValue = CMAReader("Logo")
but when trying to set a parameter to write back to the database I get an empty string
All my other parameters and the stored procedure that is being called works fine. The problem I'm having is how to retrieve the value of the selected RadioButton into the parameter.