troubleshooting Question

Multiple Listbox Auto Selection

Avatar of Figment060799
Figment060799 asked on
5 Comments1 Solution291 ViewsLast Modified:
I feel rather silly, I've been trying to get this right all night.
But I need help, so here I am.

I have a listbox which I have made @ design time called txt_categoryid.
It populates itself from an sqldatasource, and has strings for both its value and text property.
here is the listbox contents:
datatextfield                               datavaluefield
Roofing                                      RF
Electrical                                  EL
Plumbing                                PL
Drywall / Plastering                       DW
Boiler                                        BO
Paint                                        PA
Police (Illegal Activity)                   PD
Moving / Eviction                        MO
Clean Up/Debris Removal                      CL
Carpentry                                 CP
Extermination                               EX
Lawn Maintenance                     LM
Installation                                IN
Other/ Misc                              MI
General Maintenance                    GM

When I view a record from the database the 'categoryid' column is a varchar field with one or more of these values in a comadelimited manor (e.g.  BO,CL,IN,GM)

I have been trying all night to get my form to automagicaly delect the appropriate values based on the coma-delimited values.
Here is what I have been trying:
                        case "categoryid"
                              if (isnothing(request.form.get("txt_categoryid"))) then
                                    dim sCategory
                                    for each sCategory in split(print_workorder_categories(dsTable.tables(0).rows(0)(sColumnName), 1), ",") 'SPLIT THE DB VALUE INTO ARRAY FOR ITERATION
                                          'txt_categoryid.ListIndex = (Cint(sCategory)-1)   'TRY #1
                                          'txt_categoryid.Items(Cint(sCategory)-1).Selected = True  'TRY #2
                              end if


Here is my listbox:
<asp:SqlDataSource ID="dsCategory" runat="server" ConnectionString="<%$ ConnectionStrings:Assets %>" ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM [work_order_category]"></asp:SqlDataSource>
<asp:ListBox ID="txt_categoryid" runat="server" DataSourceID="dsCategory" DataTextField="type" DataValueField="type_code" SelectionMode="Multiple"></asp:ListBox>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros