• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 192
  • Last Modified:

parameters with radio button values...

I have a stored proceedure that is for a questionaire that when finished will be written to sql.  My problem is that I am not sure what coding needs to be used for the paramerter for radio button values. All my validation is currently done on the client side using javascript.
This is what I have now:

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Configuration;
using Microsoft.ApplicationBlocks.Data;

namespace RUOK
{
      /// <summary>
      /// Summary description for survey.
      /// </summary>
      public class survey : System.Web.UI.Page
      {
            protected System.Web.UI.WebControls.RadioButton radioQ1_2;
            protected System.Web.UI.WebControls.RadioButton radioQ1_1;
            protected System.Web.UI.WebControls.Label lblQ1Tip1;
            protected System.Web.UI.WebControls.RadioButton radioQ2_2;
            protected System.Web.UI.WebControls.RadioButton radioQ2_1;
            protected System.Web.UI.WebControls.RadioButton radioQ2_0;
            protected System.Web.UI.WebControls.Label lblQ2Tip;
            protected System.Web.UI.WebControls.RadioButton radioQ3_2;
            protected System.Web.UI.WebControls.RadioButton radioQ3_1;
            protected System.Web.UI.WebControls.RadioButton radioQ3_0;
            protected System.Web.UI.WebControls.Label lblQ3Tip;
            protected System.Web.UI.WebControls.RadioButton radioQ4_2;
            protected System.Web.UI.WebControls.RadioButton radioQ4_1;
            protected System.Web.UI.WebControls.RadioButton radioQ4_0;
            protected System.Web.UI.WebControls.RadioButton radioQ5_2;
            protected System.Web.UI.WebControls.RadioButton radioQ5_1;
            protected System.Web.UI.WebControls.RadioButton radioQ5_0;
            protected System.Web.UI.WebControls.RadioButton radioQ6_2;
            protected System.Web.UI.WebControls.RadioButton radioQ6_1;
            protected System.Web.UI.WebControls.RadioButton radioQ6_0;
            protected System.Web.UI.WebControls.RadioButton radioQ7_2;
            protected System.Web.UI.WebControls.RadioButton radioQ7_1;
            protected System.Web.UI.WebControls.RadioButton radioQ7_0;
            protected System.Web.UI.WebControls.RadioButton radioQ8_1;
            protected System.Web.UI.WebControls.RadioButton radioQ8_0;
            protected System.Web.UI.WebControls.RadioButton radioQ10_1;
            protected System.Web.UI.WebControls.RadioButton radioQ13_2;
            protected System.Web.UI.WebControls.RadioButton radioQ8_2;
            protected System.Web.UI.WebControls.RadioButton radioQ9_2;
            protected System.Web.UI.WebControls.RadioButton radioQ9_1;
            protected System.Web.UI.WebControls.RadioButton radioQ9_0;
            protected System.Web.UI.WebControls.RadioButton radioQ10_2;
            protected System.Web.UI.WebControls.RadioButton radioQ10_0;
            protected System.Web.UI.WebControls.RadioButton radioQ11_2;
            protected System.Web.UI.WebControls.RadioButton radioQ11_1;
            protected System.Web.UI.WebControls.RadioButton radioQ11_0;
            protected System.Web.UI.WebControls.RadioButton radioQ12_2;
            protected System.Web.UI.WebControls.RadioButton radioQ12_1;
            protected System.Web.UI.WebControls.RadioButton radioQ12_0;
            protected System.Web.UI.WebControls.RadioButton radioQ13_1;
            protected System.Web.UI.WebControls.RadioButton radioQ15_1;
            protected System.Web.UI.WebControls.RadioButton radioQ17_2;
            protected System.Web.UI.WebControls.RadioButton radioQ1_0;
            protected System.Web.UI.WebControls.RadioButton radioQ13_0;
            protected System.Web.UI.WebControls.RadioButton radioQ14_2;
            protected System.Web.UI.WebControls.RadioButton radioQ14_1;
            protected System.Web.UI.WebControls.RadioButton radioQ14_0;
            protected System.Web.UI.WebControls.RadioButton radioQ15_2;
            protected System.Web.UI.WebControls.RadioButton radioQ15_0;
            protected System.Web.UI.WebControls.RadioButton radioQ16_2;
            protected System.Web.UI.WebControls.RadioButton radioQ16_1;
            protected System.Web.UI.WebControls.RadioButton radioQ16_0;
            protected System.Web.UI.WebControls.RadioButton radioQ17_1;
            protected System.Web.UI.WebControls.RadioButton radioQ17_0;
            protected System.Web.UI.WebControls.RadioButton radioQ18_2;
            protected System.Web.UI.WebControls.RadioButton radioQ18_1;
            protected System.Web.UI.WebControls.RadioButton radioQ18_0;
            protected System.Web.UI.WebControls.RadioButton RadioGenderF;
            protected System.Web.UI.WebControls.RadioButton radioResidentY;
            protected System.Web.UI.WebControls.RadioButton radioResidentN;
            protected System.Web.UI.WebControls.RadioButton RadioGender;
            protected System.Web.UI.WebControls.RadioButton RadioGenderM;
            protected System.Web.UI.WebControls.DropDownList ddAgeRange;
            protected System.Web.UI.WebControls.TextBox hiddenTotalScore;
            protected System.Web.UI.WebControls.Label lblDateTime;
            


            private const string stpRUOKInsertNew = "stp_RUOK_InsertNew";
      
            private void Page_Load(object sender, System.EventArgs e)
            {
                  if (IsPostBack)
                  {      
                        
                        DataSet ds = new DataSet();
                        try
                        {
                          SqlParameter [] prm = new SqlParameter[21];
                              prm[0] = new SqlParameter("@agerange",this.ddAgeRange.SelectedValue + RemoveDefaultValues(this.ddAgeRange.SelectedValue));
                              prm[1] = new SqlParameter ("@gender", this.RadioGender.Checked);
                              
                              
                        ds = SqlHelper.ExecuteDataset((ConfigurationSettings.AppSettings["SQLConnectionString"]), CommandType.StoredProcedure, stpRUOKInsertNew,prm);
                        Response.Redirect("profile.aspx");
                        }
                  catch(Exception ex)
                  {
                        throw ex;
                  }
                        }
                  
            }

            #region Web Form Designer generated code
            override protected void OnInit(EventArgs e)
            {
                  //
                  // CODEGEN: This call is required by the ASP.NET Web Form Designer.
                  //
                  InitializeComponent();
                  base.OnInit(e);
            }
            
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {    
                  this.Load += new System.EventHandler(this.Page_Load);

            }
            #endregion

            

            
      }
}
0
mockweb
Asked:
mockweb
  • 4
  • 3
1 Solution
 
Bob LearnedCommented:
What kind of validation are you talking about?  What is your question really?

Bob
0
 
mockwebAuthor Commented:
i am validating the questionaire that has 18 questions and 3 possible answers using radio buttons. My question is when I try to use my stored proceedure I am not sure what property is used..
and example would be a text box with an id of txtlname would use .Text what would you use for a radio button .Checked?
 prm[0] = new SqlParameter("@lname",this.txtlname.Text);
0
 
Bob LearnedCommented:
Yes, with the RadioButton, you would use the Checked property.  What kind of parameter are you accessing with the RadioButton Checked value?

Bob
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
mockwebAuthor Commented:
i only want to insert information so i am accessing the input parameter. I am very new at this so excuse me if i am using the wrong terminology.
0
 
Bob LearnedCommented:
Ok, but what data are you trying to insert into the database that is associated with the RadioButton control?

Bob
0
 
mockwebAuthor Commented:
OK let me give you the whole thing.

I have 18 questions
each answer is a radio button with a group name (Question1), Question 2 etc
each radio button will have a value of 2, 1, or 0.

depending on what the user selects 2, 1, or 0. That is the information that I need to insert.  So say the user selects 2 as the answer I want that value  (2)written to the database.
0
 
Bob LearnedCommented:
1) I would use a RadioButtonList instead of separate RadioButton controls.

2) Then, you could use the RadioButtonList.SelectedIndex property to get the currently selected index, and write that value to the database with an Integer parameter.

Bob
0
 
Computer101Commented:
Forced accept.

Computer101
EE Admin
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now