mockweb
asked on
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.ApplicationBlock s.Data;
namespace RUOK
{
/// <summary>
/// Summary description for survey.
/// </summary>
public class survey : System.Web.UI.Page
{
protected System.Web.UI.WebControls. RadioButto n radioQ1_2;
protected System.Web.UI.WebControls. RadioButto n radioQ1_1;
protected System.Web.UI.WebControls. Label lblQ1Tip1;
protected System.Web.UI.WebControls. RadioButto n radioQ2_2;
protected System.Web.UI.WebControls. RadioButto n radioQ2_1;
protected System.Web.UI.WebControls. RadioButto n radioQ2_0;
protected System.Web.UI.WebControls. Label lblQ2Tip;
protected System.Web.UI.WebControls. RadioButto n radioQ3_2;
protected System.Web.UI.WebControls. RadioButto n radioQ3_1;
protected System.Web.UI.WebControls. RadioButto n radioQ3_0;
protected System.Web.UI.WebControls. Label lblQ3Tip;
protected System.Web.UI.WebControls. RadioButto n radioQ4_2;
protected System.Web.UI.WebControls. RadioButto n radioQ4_1;
protected System.Web.UI.WebControls. RadioButto n radioQ4_0;
protected System.Web.UI.WebControls. RadioButto n radioQ5_2;
protected System.Web.UI.WebControls. RadioButto n radioQ5_1;
protected System.Web.UI.WebControls. RadioButto n radioQ5_0;
protected System.Web.UI.WebControls. RadioButto n radioQ6_2;
protected System.Web.UI.WebControls. RadioButto n radioQ6_1;
protected System.Web.UI.WebControls. RadioButto n radioQ6_0;
protected System.Web.UI.WebControls. RadioButto n radioQ7_2;
protected System.Web.UI.WebControls. RadioButto n radioQ7_1;
protected System.Web.UI.WebControls. RadioButto n radioQ7_0;
protected System.Web.UI.WebControls. RadioButto n radioQ8_1;
protected System.Web.UI.WebControls. RadioButto n radioQ8_0;
protected System.Web.UI.WebControls. RadioButto n radioQ10_1;
protected System.Web.UI.WebControls. RadioButto n radioQ13_2;
protected System.Web.UI.WebControls. RadioButto n radioQ8_2;
protected System.Web.UI.WebControls. RadioButto n radioQ9_2;
protected System.Web.UI.WebControls. RadioButto n radioQ9_1;
protected System.Web.UI.WebControls. RadioButto n radioQ9_0;
protected System.Web.UI.WebControls. RadioButto n radioQ10_2;
protected System.Web.UI.WebControls. RadioButto n radioQ10_0;
protected System.Web.UI.WebControls. RadioButto n radioQ11_2;
protected System.Web.UI.WebControls. RadioButto n radioQ11_1;
protected System.Web.UI.WebControls. RadioButto n radioQ11_0;
protected System.Web.UI.WebControls. RadioButto n radioQ12_2;
protected System.Web.UI.WebControls. RadioButto n radioQ12_1;
protected System.Web.UI.WebControls. RadioButto n radioQ12_0;
protected System.Web.UI.WebControls. RadioButto n radioQ13_1;
protected System.Web.UI.WebControls. RadioButto n radioQ15_1;
protected System.Web.UI.WebControls. RadioButto n radioQ17_2;
protected System.Web.UI.WebControls. RadioButto n radioQ1_0;
protected System.Web.UI.WebControls. RadioButto n radioQ13_0;
protected System.Web.UI.WebControls. RadioButto n radioQ14_2;
protected System.Web.UI.WebControls. RadioButto n radioQ14_1;
protected System.Web.UI.WebControls. RadioButto n radioQ14_0;
protected System.Web.UI.WebControls. RadioButto n radioQ15_2;
protected System.Web.UI.WebControls. RadioButto n radioQ15_0;
protected System.Web.UI.WebControls. RadioButto n radioQ16_2;
protected System.Web.UI.WebControls. RadioButto n radioQ16_1;
protected System.Web.UI.WebControls. RadioButto n radioQ16_0;
protected System.Web.UI.WebControls. RadioButto n radioQ17_1;
protected System.Web.UI.WebControls. RadioButto n radioQ17_0;
protected System.Web.UI.WebControls. RadioButto n radioQ18_2;
protected System.Web.UI.WebControls. RadioButto n radioQ18_1;
protected System.Web.UI.WebControls. RadioButto n radioQ18_0;
protected System.Web.UI.WebControls. RadioButto n RadioGenderF;
protected System.Web.UI.WebControls. RadioButto n radioResidentY;
protected System.Web.UI.WebControls. RadioButto n radioResidentN;
protected System.Web.UI.WebControls. RadioButto n RadioGender;
protected System.Web.UI.WebControls. RadioButto n RadioGenderM;
protected System.Web.UI.WebControls. DropDownLi st 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",t his.ddAgeR ange.Selec tedValue + RemoveDefaultValues(this.d dAgeRange. SelectedVa lue));
prm[1] = new SqlParameter ("@gender", this.RadioGender.Checked);
ds = SqlHelper.ExecuteDataset(( Configurat ionSetting s.AppSetti ngs["SQLCo nnectionSt ring"]), CommandType.StoredProcedur e, 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.P age_Load);
}
#endregion
}
}
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.ApplicationBlock
namespace RUOK
{
/// <summary>
/// Summary description for survey.
/// </summary>
public class survey : System.Web.UI.Page
{
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
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",t
prm[1] = new SqlParameter ("@gender", this.RadioGender.Checked);
ds = SqlHelper.ExecuteDataset((
Response.Redirect("profile
}
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.P
}
#endregion
}
}
ASKER
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);
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
Yes, with the RadioButton, you would use the Checked property. What kind of parameter are you accessing with the RadioButton Checked value?
Bob
Bob
ASKER
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.
Ok, but what data are you trying to insert into the database that is associated with the RadioButton control?
Bob
Bob
ASKER
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Forced accept.
Computer101
EE Admin
Computer101
EE Admin
Bob