Update Multiple Selected Item from Checkboxlist to SQL server database
-
Hi All, I have a checkboxlist(created from db) on form where user can selected multiple items when click on update button the form send the data to sql server database. This work fine, the problem I have when the user open the form for the same record number and want change the checkboxlist items. How do I go about doing this ? For example: first time around user selected item 1,3,7,9 and 10 Second time around user selected item 2,3,5,7,9 and 10. Any assistance is greatly apprecaited. please provide codes example. Thanks DocHoliday. my code for the inserting to the db, the field that get insert are Application_id, Item# and Module (primary Key in db). Protected Sub GetCheckedModule() Dim MyItem As ListItem mstrSelectedColumns = "" For Each MyItem In chkbModule.Items If MyItem.Selected = True Then Session("Module") = MyItem.Value Insert_SelectedModule() End If Next End Sub
-
Hi All, I have a checkboxlist(created from db) on form where user can selected multiple items when click on update button the form send the data to sql server database. This work fine, the problem I have when the user open the form for the same record number and want change the checkboxlist items. How do I go about doing this ? For example: first time around user selected item 1,3,7,9 and 10 Second time around user selected item 2,3,5,7,9 and 10. Any assistance is greatly apprecaited. please provide codes example. Thanks DocHoliday. my code for the inserting to the db, the field that get insert are Application_id, Item# and Module (primary Key in db). Protected Sub GetCheckedModule() Dim MyItem As ListItem mstrSelectedColumns = "" For Each MyItem In chkbModule.Items If MyItem.Selected = True Then Session("Module") = MyItem.Value Insert_SelectedModule() End If Next End Sub
One, learn to format any code snippets you post here. Bind the checklistbox to the datasource
I know the language. I've read a book. - _Madmatt
-
Hi All, I have a checkboxlist(created from db) on form where user can selected multiple items when click on update button the form send the data to sql server database. This work fine, the problem I have when the user open the form for the same record number and want change the checkboxlist items. How do I go about doing this ? For example: first time around user selected item 1,3,7,9 and 10 Second time around user selected item 2,3,5,7,9 and 10. Any assistance is greatly apprecaited. please provide codes example. Thanks DocHoliday. my code for the inserting to the db, the field that get insert are Application_id, Item# and Module (primary Key in db). Protected Sub GetCheckedModule() Dim MyItem As ListItem mstrSelectedColumns = "" For Each MyItem In chkbModule.Items If MyItem.Selected = True Then Session("Module") = MyItem.Value Insert_SelectedModule() End If Next End Sub
DocHoliday66 wrote:
when the user open the form for the same record number and want change the checkboxlist items. How do I go about doing this
You need to do the following: 1. Check the details about that 'record' number already exists or not. 2. If you find that there are items selected and saved in DB then retrieve that data using a Select query. 3. Once you have the data retrieved, go in a loop and explicitly select those items in the checkboxlist.