Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. how to use radio button in placeholder

how to use radio button in placeholder

Scheduled Pinned Locked Moved ASP.NET
questiondatabasetutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LovelyHelp
    wrote on last edited by
    #1

    I have my radio button declare as Dim optMulChoice As New RadioButton() Dim optTrueFalse As New RadioButton() optMulChoice.Text = "Multiple Answer" optMulChoice.GroupName = "rbtType" optMulChoice.ID = "rbtMulChoice" optMulChoice.Checked = True plhHolder.Controls.Add(optMulChoice) optTrueFalse.Text = "True/False" optTrueFalse.GroupName = "rbtType" optTrueFalse.ID = "rbtTrueFalse" plhHolder.Controls.Add(optTrueFalse) which it will keep at place holder. now I will like to insert the selected value into my database when 'ADD' button click. myCommand = New SqlCommand("INSERT INTO t_quiz (q_type) VALUES (@type)", myConnection) myCommand.Parameters.Add("@type", SqlDbType.Bit, 1).Value = rbtType.selectedItem.value But, it showing rbtType is not declare. How am I going to get the value of my selected radio button? What is the correct way to do it?

    P 1 Reply Last reply
    0
    • L LovelyHelp

      I have my radio button declare as Dim optMulChoice As New RadioButton() Dim optTrueFalse As New RadioButton() optMulChoice.Text = "Multiple Answer" optMulChoice.GroupName = "rbtType" optMulChoice.ID = "rbtMulChoice" optMulChoice.Checked = True plhHolder.Controls.Add(optMulChoice) optTrueFalse.Text = "True/False" optTrueFalse.GroupName = "rbtType" optTrueFalse.ID = "rbtTrueFalse" plhHolder.Controls.Add(optTrueFalse) which it will keep at place holder. now I will like to insert the selected value into my database when 'ADD' button click. myCommand = New SqlCommand("INSERT INTO t_quiz (q_type) VALUES (@type)", myConnection) myCommand.Parameters.Add("@type", SqlDbType.Bit, 1).Value = rbtType.selectedItem.value But, it showing rbtType is not declare. How am I going to get the value of my selected radio button? What is the correct way to do it?

      P Offline
      P Offline
      p2pNaveen
      wrote on last edited by
      #2

      Declare the RadioButtons at the class level and create the instance where it is needed. For e.g(i am writing this in C#) Class ClassName { RadioButton optMulChoice; //declare it here private void Page_Load(object sender, System.EventArgs e) { optMulChoice = new RadioButton(); ..... .... ////your code goes here } private void Button1_Click(object sender, System.EventArgs e) { myCommand = New SqlCommand("INSERT INTO t_quiz (q_type) VALUES (@type)", myConnection); myCommand.Parameters.Add("@type", SqlDbType.Bit, 1).Value =rbtType.SelectedItem .Value; } } Naveen G

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups