Skip to content
Loading
  • +1
    Here EMPIDTxt is also giving error
    +1
  • +1
    the name emptxt does not contain in the current context
    +1
  • Sanwar Ranwa
    +1
    copy the id from aspx and paste in the following query your textbox id is not match
    +1
  • +1
    I am doing the same but still not working
    +1
  • +1
    Following is the code for registration.aspx.cs 
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data.SqlClient;
    using System.Data;
    using System.Data.Sql;
    using System.Configuration;
    namespace RegistrationForm
    {
    public partial class Registration : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {
    if (IsPostBack)
    {
    SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["RegiConnectionString"].ConnectionString);
    conn.Open();
    string checkuser = "select count(*) from registrationForm where EmpId='" + EmpIdTxt.Text + "'";
    SqlCommand cmd = new SqlCommand(checkuser, conn);
    int temp = Convert.ToInt32(cmd.ExecuteScalar().ToString());
    if (temp == 1)
    {
    Response.Write("Employee Already Exist");
    }
    conn.Close();
    }
    }
    protected void Save_Click(object sender, EventArgs e)
    {
    try
    {
    SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["RegiConnectionString"].ConnectionString);
    conn.Open();
    string insertQuery = "insert into RegisterationForm(EmpId,Religion,Nationality,Gender,Residential asddress)values (@EmpId,@Religion,@Nationality,@Gender,@Residential Address)";
    SqlCommand cmd = new SqlCommand(insertQuery, conn);
    cmd.Parameters.AddWithValue("@EmpId", EmpIdTxt.Text);
    cmd.Parameters.AddWithValue("@Religion", ReligionTxt.Text);
    cmd.Parameters.AddWithValue("@Nationality", NationalityTxt.Text);
    cmd.Parameters.AddWithValue("@Gender", GenderTxt.Text);
    cmd.Parameters.AddWithValue("@Residentail Address",ResidentaiolAddressTxt.Text);
    cmd.ExecuteNonQuery();
    Response.Write("Employee registeration Successfully!!!thank you");
    conn.Close();
    }
    catch (Exception ex)
    {
    Response.Write("error" + ex.ToString());
    }
    }
    protected void ReligionTxt_TextChanged(object sender, EventArgs e)
    {
    }
    protected void Edit_Click(object sender, EventArgs e)
    {
    }
    }
    }
    +1
  • Sanwar Ranwa
    0
    Share your aspx page
    0
  • 0
    I am not able to send that direct drom c Drive. How to send ?
    0
  • Sanwar Ranwa
    0
    Just copy code of this perticular page and share
    0
  • Sanwar Ranwa
    0
    What is error message
    0