Tech
Forums
Jobs
Books
Events
Live
Interviews Prep
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
5
Reply
How to make multiple checkbox add to database
Joma Rajab
Aug 11 2016 10:53 AM
241
Reply
I need to add more one selected item from checkbox to database but when I select more one I could not for one Item it works fine
this the code
please help
thanks
cmd.CommandText =
"If Not Exists(select * from dbo.ModuleRelation where UId=@UId and MId=@MId) Begin insert into dbo.ModuleRelation (UId, MId, MName) values(@UId, @MId, @MName) End"
;
cmd.Connection = conn;
foreach
(ListItem item
in
chkModules.Items)
if
(item.Selected ==
true
)
{
conn.Open();
cmd.Parameters.Clear();
cmd.Parameters.AddWithValue(
"@UId"
, DropDownList1.SelectedItem.ToString());
cmd.Parameters.AddWithValue(
"@MId"
, item.Value.ToString());
cmd.Parameters.AddWithValue(
"@MName"
, item.Text.ToString());
chkModules.Visible =
false
;
cmd.ExecuteNonQuery();
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
5
)
Next Recommended Forum
How to Store CheckBox Checked and Unchecked in Hidden Field
secure web api example