| | |
Inserting checkbox values into one field
Please support our ASP.NET advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: May 2009
Posts: 4
Reputation:
Solved Threads: 0
hi
I have a checkboxes on my page (.aspx) like
checkbox1 - item1
checkbox2 - item2
checkbox3 - item3
etc
what i want is that when a user selects certain checkboxes
they should be inserted into a table called
customer which has fields (customer id and actions)
the data should be inserted as
customerid actions
1 item1,item2,item3
2 item1,item3
3 etc..
i.e all the values should be inserted into database into one field separated by commas.
Thanks
I have a checkboxes on my page (.aspx) like
checkbox1 - item1
checkbox2 - item2
checkbox3 - item3
etc
what i want is that when a user selects certain checkboxes
they should be inserted into a table called
customer which has fields (customer id and actions)
the data should be inserted as
customerid actions
1 item1,item2,item3
2 item1,item3
3 etc..
i.e all the values should be inserted into database into one field separated by commas.
Thanks
Hi ebosysindia,
Please use CheckBoxList control.
and to check which item is selected :
or if you want to insert the items into database
Please use CheckBoxList control.
and to check which item is selected :
ASP.NET Syntax (Toggle Plain Text)
Dim V As String = "" Dim I As SByte For i = 0 To CheckBoxList1.Items.Count - 1 If CheckBoxList1.Items(I).Selected = True Then If V = "" Then V = CheckBoxList1.Items(I).Value Else V = V & "," & CheckBoxList1.Items(I).Value End If End If Next TextBox1.Text = V
or if you want to insert the items into database
ASP.NET Syntax (Toggle Plain Text)
Dim V As String = "" Dim I As SByte Dim SQL As String = "" Dim SQLList As New StringBuilder For i = 0 To CheckBoxList1.Items.Count - 1 If CheckBoxList1.Items(I).Selected = True Then SQL = "INSERT INTO CUSTOMER VALUES('0001','" & CheckBoxList1.Items(I).Value & "')" & vbCrLf SQLList.Append(SQL) End If Next TextBox1.Text = SQLList.ToString
NEVER NEVER NEVER GIVE UP
•
•
Join Date: May 2009
Posts: 4
Reputation:
Solved Threads: 0
•
•
•
•
Hi ebosysindia,
Please use CheckBoxList control.
and to check which item is selected :
ASP.NET Syntax (Toggle Plain Text)
Dim V As String = "" Dim I As SByte For i = 0 To CheckBoxList1.Items.Count - 1 If CheckBoxList1.Items(I).Selected = True Then If V = "" Then V = CheckBoxList1.Items(I).Value Else V = V & "," & CheckBoxList1.Items(I).Value End If End If Next TextBox1.Text = V
or if you want to insert the items into database
ASP.NET Syntax (Toggle Plain Text)
Dim V As String = "" Dim I As SByte Dim SQL As String = "" Dim SQLList As New StringBuilder For i = 0 To CheckBoxList1.Items.Count - 1 If CheckBoxList1.Items(I).Selected = True Then SQL = "INSERT INTO CUSTOMER VALUES('0001','" & CheckBoxList1.Items(I).Value & "')" & vbCrLf SQLList.Append(SQL) End If Next TextBox1.Text = SQLList.ToString
Thanks for giving asnwer
![]() |
Similar Threads
- inserting multiple selection from checkbox in to one column (JSP)
- sending a array to next page (PHP)
- inserting checkbox values in mysql +PHP (PHP)
- How to delete using checkboxes (PHP)
Other Threads in the ASP.NET Forum
Views: 1049 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.net 2.0 3.5 ajax appliances application asp asp.net beginner box browser businesslogiclayer button c# cac chat checkbox child class compatible complex content contenttype control countryselector courier database datagrid datagridview datalist deployment development dgv dialog dropdown dropdownmenu dynamic dynamically edit embeddingactivexcontrol feedback fileuploader fill findcontrol flash flv folder form gridview gudi identity iis image javascript languages list maps menu mobile mssql nameisnotdeclared novell opera order problem profile ratings redirect refer registration relationaldatabases response.redirect rows search security select serializesmo.table sessionvariables silverlight smoobjects software sql ssl tracking treeview typeof validatedate validation vb vb.net vista visual-studio visualstudio vs2008 web webapplications webarchitecture webdevelopment wizard xsl





