Click here to Skip to main content
13,251,495 members (56,232 online)
Rate this:
Please Sign up or sign in to vote.
See more:

(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);
       int i= cmd.ExecuteNonQuery();
       if (i > 0)
           Label6.Text = ("Record Added Successfuly");
           //MessageBox.Show("Record Added");

           Label6.Text = ("Record not Added");
           //MessageBox.Show("Record not Added");          
       Label6.Enabled = true;
       Button2.Enabled = false;

Thank you very much for one and all

Thanks & Regards
Posted 18-Nov-12 21:34pm
Updated 21-Nov-12 2:38am
deenujii 19-Nov-12 7:55am
what type of error u getting here????????
post ur error below comment or question????
Sreeraam_d 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.171114.1 | Last Updated 21 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100