Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
Hi,
 
(Am unable to insert Radio Button selected Text, Checkboxlist selected text in database please help me to solve this problem).
 
I had solved this problem the following code is working now
 
protected void Button1_Click(object sender, EventArgs e)
    {
        string EmpNo = TextBox1.Text;
        string EmpName = TextBox2.Text;
        string Designation = DropDownList1.SelectedItem.Text;
        string Department = DropDownList2.SelectedItem.Text;
        decimal Salary = Convert.ToDecimal(TextBox3.Text);
        string Gender = RadioButtonList1.SelectedItem.Text;
        string Preference = CheckBoxList1.SelectedItem.Text;      
       
 
        SqlConnection con = new SqlConnection("Server=********;uid=sa;password=*****; database=sreeramdasari;");
        SqlCommand cmd = new SqlCommand("insert into EmployeeDetails values(@EmpNo,@EmpName,@Designation,@Department,@Salary,@Gender,@Preference)", con);
 
        
    
        cmd.Parameters.AddWithValue("@EmpNo", EmpNo);
        cmd.Parameters.AddWithValue("@EmpName", EmpName);
        cmd.Parameters.AddWithValue("@Designation", Designation);
        cmd.Parameters.AddWithValue("@Department", Department);
        cmd.Parameters.AddWithValue("@Salary", Salary);
        cmd.Parameters.AddWithValue("@Gender",Gender);
        cmd.Parameters.AddWithValue("@Preference",Preference);
        con.Open();
 
       
       int i= cmd.ExecuteNonQuery();
       if (i > 0)
       {
           Label6.Text = ("Record Added Successfuly");
           //MessageBox.Show("Record Added");
       }
 

       else
       {
           Label6.Text = ("Record not Added");
           //MessageBox.Show("Record not Added");          
       }
       Label6.Enabled = true;
       Button2.Enabled = false;
 
        con.Close();            
}
 
Thank you very much for one and all
 
Thanks & Regards
Sreeram
Posted 18-Nov-12 20:34pm
Edited 21-Nov-12 1:38am
106.7K
v5
Comments
deenujii at 19-Nov-12 7:55am
   
what type of error u getting here????????
post ur error below comment or question????
Sreeraam_d at 21-Nov-12 7:30am
   
Hi Deenu,
 
I solved this problem here i put wrong code now the following code
string Gender = RadioButtonList1.SelectedItem.Text;
string Preference = CheckBoxList1.SelectedItem.Text;
 
is working for me. Thank you very much for the support.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web01 | 2.8.140709.1 | Last Updated 21 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid