Click here to Skip to main content
15,917,456 members

Comments by saurabh bhaedwaj (Top 1 by date)

saurabh bhaedwaj 12-Dec-12 1:39am View    
when I make it with the help of asp server control but now i'm tryin with html control but everything is complete but my data not saved .my checkbox is fine work. but data not saved in database. I attach my code to you.

""
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Drawing;

public partial class allrishteymaster : System.Web.UI.MasterPage
{
string constr = ConfigurationManager.ConnectionStrings["constr"].ToString();
protected void Page_Load(object sender, EventArgs e)
{
//start making session
Session["email"] = Textmail;
Session["password"] = Textpassword;
Session["profilefor"] = profilefor;
Session["name"] = Textusername;
Session["gender"] = Radiomale;
Session["gender"] = Radiofemale;
Session["dd"] = dd;
Session["mm"] = mm;
Session["yy"] = yy;
Session["religion"] = religion;
Session["mothertongue"] = mothertongue;
Session["livingin"] = livingin;
//end making session
}
protected void regissub_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(constr );
SqlCommand cmd = new SqlCommand("insert into userregisteration" + "(uid,email,password,username,poprfilefor,gender,dob,religion,mothertongue,livingin,registrationdate)" + "values" + "(@uid,@email,@password,@username,@poprfilefor,@gender,@dob,@religion,@mothertongue,@livingin,@registrationdate)",con);
try
{
con.Open();
if (Checkbox1.Checked == true)
{
cmd.Parameters.Add(new SqlParameter("@email", Textmail));
cmd.Parameters.Add(new SqlParameter("@password", Textpassword));
cmd.Parameters.Add(new SqlParameter("@username", Textusername));
cmd.Parameters.Add(new SqlParameter("@poprfilefor", profilefor.SelectedIndex));
cmd.Parameters.Add(new SqlParameter("@gender", Radiomale.ToString()));
cmd.Parameters.Add(new SqlParameter("@gender", Radiofemale.ToString()));
cmd.Parameters.Add(new SqlParameter("@dob", dd.SelectedIndex + "-" + mm.SelectedIndex + "-" + yy.SelectedIndex));
cmd.Parameters.Add(new SqlParameter("@religion", religion.SelectedIndex));
cmd.Parameters.Add(new SqlParameter("@mothertongue", mothertongue.SelectedIndex));
cmd.Parameters.Add(new SqlParameter("@livingin", livingin.SelectedIndex));
Response.Redirect("RgistrationProfile2.aspx");
cmd.ExecuteNonQuery();

}
else
{
error.Text = "Check Privacy And T&C";
}
}
catch
{
con.Close();
}

}

}
""