Click here to Skip to main content
16,012,223 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to insert the value i set for a radio button into database.
I get the error on building my project: operator '&' is not defined for types 'String' and 'System.web.ui.attributecollection'

I set the value of the radio on pageload:
VB
Dim RBS As RadioButton = CType(TypeForm.FindControl("RBS"), RadioButton)
RBS.Attributes.Add("value", "S")


cmd.CommandText = "INSERT INTO PTPropertyType (PTTypeName, PTType, PTSM, PTAudit, PTUser) VALUES ('" & name.Text & "', '" & type.Text & "', '" & RBS.Attributes["value"].ToString() & "', GetDate(), '" & Session("UserInfo") & "')"

is there a way to do this?
Posted

1 solution

Pass the value of the radio when checked as variable
example

VB
Dim ValueCheck as String = ""
If Radio.Checked = true Then ValueCheck = "S" Else ValueCheck = "N"
 
cmd.CommandText = "INSERT INTO PTPropertyType (PTTypeName, PTType, PTSM, PTAudit, PTUser) VALUES ('" & name.Text & "', '" & type.Text & "', '" & ValueCheck  & "', GetDate(), '" & Session("UserInfo") & "')"
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900