Click here to Skip to main content
11,802,762 members (74,152 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: SQL-server-2005 C# Windows , +
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 19:33pm
Edited 7-Dec-12 19:36pm
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
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;

For reference follow the following link. Insert Query

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

insert into table name (column name) values ('" & checkbox1.checked & "')
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 KrunalRohit 366
1 OriginalGriff 365
2 CPallini 270
3 F-ES Sitecore 270
4 Sergey Alexandrovich Kryukov 239
0 OriginalGriff 2,950
1 Maciej Los 1,910
2 KrunalRohit 1,862
3 CPallini 1,735
4 Richard MacCutchan 1,157

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