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:
Drywall / Plastering DW
Police (Illegal Activity) PD
Moving / Eviction MO
Clean Up/Debris Removal CL
Lawn Maintenance LM
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:
if (isnothing(request.form.get("txt_categoryid"))) then
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
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>