CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Multiple ListBox

Print topic Send  topic

Author Message
Mark
Posted: 04/26/2004, 3:13 PM

How do you insert Multiple ListBox Values (or check box) into one field via asp and MSSQL.

Thanks in advance.
peterr


Posts: 5971
Posted: 04/26/2004, 3:21 PM

Please refer to Multi-select Listbox examples (Working with Multiple Selections) in CCS Example Pack.
http://docs.codecharge.com/studio/html/ProgrammingTechn...xamplePack.html
http://examples.codecharge.com/ExamplePack/ManyToManyLi...ManyListbox.php
http://examples.codecharge.com/ExamplePack/ManyToManyCh...anyCheckbox.php

_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Mark Hope
Posted: 04/26/2004, 3:34 PM

Thanks for the quick reply, Ill check this out :-)
peterr


Posts: 5971
Posted: 04/26/2004, 3:39 PM

Actually, I just realized that you asked how to insert those values into a single field, while our examples insert those values into multiple fields (in another reference table).
I still hope that the examples will be helpful but if you need additional help please feel free to ask.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Mark
Posted: 04/27/2004, 5:14 PM

This example wasn't what I was looking for, I need a way to insert multiple values into one field, any examples would be appreciated :-)
peterr


Posts: 5971
Posted: 04/27/2004, 9:32 PM

Great. This is so much easier. The example is only a bit complex because it splits these values into multiple fields, but you don't need to do all that.
Here is the only line of code from that example that you'd need:
Request.Form("ProjectList")
(in your case replace "ProjectList" with the name of the multi-select Checkbox or Listbox)

This will provide you with the values you want and you can save them into any field you like. For example:
FormName.TextBox1.Value = Request.Form("ProjectList")
(in the "Before Insert" and "Before Update" events)
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Mark
Posted: 04/28/2004, 3:23 PM

Great, thanks so much, Ill try this now :-)
Mark
Posted: 04/28/2004, 3:38 PM

It works, it works… Thanks so much. :-D
pcfountain

Posts: 35
Posted: 05/09/2004, 7:55 AM

Yes, this does work for inserting/updating the data, but it does not work for displaying the data next time you load the record form. How do you get the correct checkboxes to be checked the next time you load the form with an existing record? I have seen the example and tried some various code using the Split() function, but nothing is working for me.
_________________
Paul Fountain
http://www.pcfountain.com
View profile  Send private message
pcfountain

Posts: 35
Posted: 06/08/2004, 10:01 PM

(bump)
Does anybody know how to select the correct checkboxes when you store the values as a comma-separated list, as shown in peterr's response? Why would CCS have checkbox lists when you can't easily store and retrieve the data with multiple selections? :(
_________________
Paul Fountain
http://www.pcfountain.com
View profile  Send private message
peterr


Posts: 5971
Posted: 06/08/2004, 11:27 PM

Paul,

My guess is that using checkbox list to store comma-separated lists is less common than using it with many-to-many relations as shown in our examples. Therefore if we implemented the other method then you could easily store and retrieve the data with multiple selections, but still couldn't use it to store comma-separated list. Therefore the current solution is rather more open and gives the developer the choice of how to use it. We may also implement/automate couple variants in the future, so it is good to see the various methods used with the checkbox list.
Currently, if your question was "how to use checkbox list to store and retrieve the data with multiple selections" then I would refer you to our many-to-many examples.
But if you specifically need to use a comma-separated list then unfortunately we don't have an example. I suspect that it would only require several lines of code to work. You could contact our support if no one else responds with details on the forums.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
pcfountain

Posts: 35
Posted: 06/09/2004, 6:51 AM

Thanks for the reply, Peter. I am currently working with support and hopefully they can come through for me. One thing that bugs me about the many-to-many example is it uses two undocumented properties for a checkbox list, "IsMultiple" and "MultipleValues". These are not in the manual anywhere, and they are not standard ASP object properties. Is there any documentation on these properties?
_________________
Paul Fountain
http://www.pcfountain.com
View profile  Send private message
pcfountain

Posts: 35
Posted: 06/10/2004, 11:23 AM

I have finally found the solution and I thought I'd share it on these forums since this seems like a pretty common thing that people will want to do. You have to select the field from the database, then load it into an array variable using the Split() function, then load the checkbox list using the AddItem() function. Sample code is shown below, I placed it in the Before Show event. Of course you will need to substitue your own field names and database connection name.

Dim ListDescriptionSelf  
Dim TempArray  
Dim i  
  
'Populate the DescriptionSelf CheckBox list  
ListDescriptionSelf = CCDLookup("DescriptionSelf", "Nanny_registration", "userid =" & Session("UserID"), DBnanny)  
If IsNull(ListDescriptionSelf) = False Then  
  PersonalInformation.DescriptionSelf.IsMultiple = True  
  TempArray = Split(ListDescriptionSelf,", ")  
  for i=0 to UBound(TempArray)  
    PersonalInformation.DescriptionSelf.AddValue(TempArray(i))  
  next  
End If  

_________________
Paul Fountain
http://www.pcfountain.com
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.