pr3mium
Posts: 31
|
Posted: 03/09/2004, 12:12 AM |
|
Hi there,
I'm wondering if it's possible to easily generate a multiselect listbox, which would show TWO fields from the table. For example one row would be something like "<field1> - <field2>"?
Usually you can select one column for listbox's textcolumn.
Can I modify the row like:
listbox1.TextColumn = "field1" & "field2"
|
|
|
peterr
Posts: 5971
|
Posted: 03/09/2004, 2:14 AM |
|
You can use the approprioate SQL in the Data Source for your listbox, for example:
SELECT customer_id, customer_name & ' - ' & customer_phone FROM customers ORDER BY customer_name
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
pr3mium
Posts: 31
|
Posted: 03/09/2004, 2:25 AM |
|
Well, I managed to query the data OK, but in the listbox properties, when I want to select its textcolumn, I can select only one of the columns, not two.
I'd like to do the following:
Listbox's SQL datasource is:
SELECT object_id,object,objecttype FROM table ORDER BY objecttype, object
Bound column in Listbox's properties: object_id
Now, I would like the Text column property to be something like objecttype & " - " & object
|
|
|
peterr
Posts: 5971
|
Posted: 03/09/2004, 2:32 AM |
|
I tested the first solution that I provided and it works for me. Once you specify the SQL that uses both fields then the new "field" shows up in the Bound property and you can select it there.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
pr3mium
Posts: 31
|
Posted: 03/09/2004, 3:21 AM |
|
I guess, I can't handle english well enough to explain what I want to do. Yes, the listbox of the Text Column property contains all the fields that are selected by SQL, but I can't select two of them at once.
I'd like to have a multiselect listbox that would be something like that:
<field1> - <field1_type>
<field2> - <field2_type>
<field3> - <field3_type>
etc
This is what user would see on the webpage. At the moment I can have a listbox either this way:
<field1>
<field2>
<field3>
...or that way:
<field1_type>
<field2_type>
<field3_type>
|
|
|
peterr
Posts: 5971
|
Posted: 03/09/2004, 10:44 AM |
|
What I explained above does exactly what you described. If you try it, you should see what I mean. Simply enter the query like I suggested, but using your own fields, and it will work.
I used the "Intranet" example database included with CCS, so you can use it as well and try the exact query that I used.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
peterr
Posts: 5971
|
Posted: 03/09/2004, 10:50 AM |
|
BTW, assuming that my proposed solution is the right one, feel free to ask questions if you run into any issues or don't understand something.
I only modified two places: entered the above SQL query in the "Data Source" property of the listbox, and then the new combined field in the "Text Column" property.
CCS simply displays the columns returned by the query, thus if your query combines 2 fields then CCS will see it as one combined field, usually called "Expr1001" but could be something else if you use an alias.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
pr3mium
Posts: 31
|
Posted: 03/09/2004, 10:14 PM |
|
OK, I tried the following SQL clause:
SELECT object_id,object & ' - ' & objecttype FROM table ORDER BY objecttype, object
If I try to test the syntax, it shows me the errormessage "Invalid operator for data type. Operator equals boolean AND, type equals nvarchar."
|
|
|
pr3mium
Posts: 31
|
Posted: 03/09/2004, 10:33 PM |
|
Sorry, I guess I just made the wrong query. I did some research on SELECT AS queries and the query that worked for me was:SELECT object_id, (object + ' - ' + objecttype) as 2cols FROM table ORDER BY 2cols
Thanks for the good nerve
|
|
|
peterr
Posts: 5971
|
Posted: 03/09/2004, 11:10 PM |
|
Not a problem. I'm glad you got it working
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
|