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();

Midhun TpRank #388 · 6.5K reputationPosted Aug 11, 2016, 7:29 AM EDT
Midhun TpRank #388 · 6.5K reputationPosted Aug 11, 2016, 7:01 AM EDT
Joma Rajab125 reputationPosted Aug 11, 2016, 7:14 AM EDT
Joma Rajab125 reputationPosted Aug 11, 2016, 7:32 AM EDT
Midhun TpRank #388 · 6.5K reputationPosted Aug 11, 2016, 7:46 AM EDT