Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hi all
 
I have 3 check box in my page along with other controls..
please tell me how to right the code to insert the value of check box selected by the user.
 
Thank you
Posted 7-Dec-12 20:33pm
Edited 7-Dec-12 20:36pm
v2
Comments
Tadit Dash at 8-Dec-12 1:35am
   
What language you are using for coding ?
Please tag that with your question.
Tadit Dash at 8-Dec-12 1:43am
   
Can you show us any code, what you have tried so far ?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi snehasis,
 
If you are using sql server then you can try the following code.
 
INSERT INTO (TableName) (Column Names) VALUES (@checkBox1, @checkBox2, @checkBox3)
 
Here @checkBox1, @checkBox2, @checkBox3 are the parameters to the insert statement.
 
For C# Code you can try the following code.
 
foreach (DataListItem item in Security1.Items) {
        CheckBox CheckBox1 = (CheckBox)item.FindControl("CheckBox1");
 
        if (CheckBox1.Checked) {
            HiddenField h = (HiddenField)item.FindControl("FeaID");
            string add = "Insert into Carfeature (RecID,FeatureID) values ((select Max(RecID) from record),@FeatureID)";
            cmd[k] = new SqlCommand();
            cmd[k].CommandType = CommandType.Text;
            cmd[k].Parameters.Add("@FeatureID", SqlDbType.Int).Value = h.Value;
            cmd[k].CommandText = add;
            k++;
        }
}
 
For reference follow the following link. Insert Query
 
Thanks
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

insert into table name (column name) values ('" & checkbox1.checked & "')
  Permalink  
Comments
snehasish nandy at 8-Dec-12 1:46am
   
Please check the question..i told i have 3 check boxes..

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

  Print Answers RSS
0 Maciej Los 474
1 ridoy 420
2 DamithSL 180
3 OriginalGriff 179
4 Richard MacCutchan 160
0 OriginalGriff 8,033
1 DamithSL 6,179
2 Sergey Alexandrovich Kryukov 5,538
3 Maciej Los 5,508
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web04 | 2.8.141223.1 | Last Updated 8 Dec 2012
Copyright © CodeProject, 1999-2014
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