amol shelke

amol shelke

  • NA
  • 3
  • 2.6k

how to save checked item into database.

Apr 7 2012 6:29 AM
hello,
can any one tell me how to insert checked item to a database..i have following code.

protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
SqlConnection con = new SqlConnection(strConnection);
        con.Open();
        cmd = new SqlCommand("Insert Into UserCreation(FullName,UserName,Email,PhoneNo,RegionID,StateId,CityID,Password,SecurityQue,SecurityAns,MenuMasterID) VALUES(@FullName,@UserName,@Email,@PhoneNo,@RegionID,@StateId,@CityID,@Password,@SecurityQue,@SecurityAns,@MenuMasterID)", con);
        cmd.CommandType = CommandType.Text;
        cmd.Parameters.AddWithValue("@FullName", txtFullname.Text);
        cmd.Parameters.AddWithValue("@UserName", txtUserName.Text);
        cmd.Parameters.AddWithValue("@Email", txtEmail.Text);
        cmd.Parameters.AddWithValue("@PhoneNo", txtPhoneno.Text);
        cmd.Parameters.AddWithValue("@RegionID", DdlRegion.SelectedValue);
        cmd.Parameters.AddWithValue("@StateId", DdlState.SelectedValue);
        cmd.Parameters.AddWithValue("@CityID", DdlCity.SelectedValue);
        cmd.Parameters.AddWithValue("@Password", txtPassword.Text);
        cmd.Parameters.AddWithValue("@SecurityQue", txtSecurityquestion.Text);
        cmd.Parameters.AddWithValue("@SecurityAns", txtSecurityanswer.Text);
        cmd.Parameters.AddWithValue("@MenuMasterID",chkmenuRights.SelectedItem);
        cmd.ExecuteNonQuery();
        con.Close();
        
        ClientScript.RegisterStartupScript(this.GetType(), "Hello", "alert('Successfully created a user');", true);
        txtFullname.Text = "";
        txtUserName.Text = "";
        txtEmail.Text = "";
        txtPhoneno.Text = "";
        txtPassword.Text = "";
        txtConfirmpassword.Text = "";
        txtSecurityquestion.Text = "";
        txtSecurityanswer.Text = "";
        DdlRegion.SelectedIndex = 0;
        DdlState.SelectedIndex = 0;
        DdlCity.SelectedIndex = 0;

    }

pls help me.
thanx.




Answers (3)