CodeCharge Studio
search Register Login  

Visual Web Reporting

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

YesSoftware Forums -> CodeCharge Studio -> General/Other

 Assign DB Column(s) to Label and or Text box.

Print topic Send  topic

Author Message
Rocket

Posts: 45
Posted: 12/02/2010, 11:15 PM

Okay, sorry folks but this will be a dumb one.

I have a form with a Label (was a DB column). I want to contatenate two DB fields to be displayed in this label.

Now I know that I saw this somewhere, but just can't find it. I guess my problem is is that I forgot how to referrence the Label Name in the Before Show event. i know where to place the code. For example: label_name = db_field1 & " " & db_field2.

Sorry for the rookie question, especially after a month or so.

Cheers and thanks.
View profile  Send private message
datadoit
Posted: 12/03/2010, 6:16 AM

Many ways to skin this cat, but the simplest is probably setting the
label's Default Value property to:

$Container->DataSource->f("db_field1") . " " .
$Container->DataSource->f("db_field2")

Those field values must be part of your datasource's selection list.
Rocket

Posts: 45
Posted: 12/03/2010, 7:12 AM

And as usual, I didn't post correctly and enuff intel. I am using (but I understand the code you provided except $Container - but no biggy).

When I use the builder to gen a grid, I of course select the columns I want (firstname, lastname,website,email etc).

What I wanted to do was to concatenate say 1stname & " " & lastname in column 1, website and email in col2 and so one. The problem is is that when I change 1stname to textbox (or label) and assign the db columns to it it works. I then remove col2 (lastname) and then it fails, which makes sense because the referrence to lastname is gone. So then I simply contatenated firstname and lastname (using the db column names) and that worked, but again removing col2 goes foobar again.

So now I am trying to use the concat in my sql query and create and alias called AcctName, but that gens all kinds of errors.

Clearly I still have way more to learn. Onwards and upwards - yahoo!
View profile  Send private message
datadoit
Posted: 12/03/2010, 7:38 AM

CodeCharge is object-oriented, so pretty much everything on your page
generated by CCS will be an object. In this case, $Container is your
grid object. $Components will be the, um, components within the
container, and can be referenced from their individual events.

When you refer to $Container->YourField->GetValue(), then you're
referring to the object that is built and displayed by CodeCharge. If
you remove the object from display (delete the text box or label
associated to the data field), then obviously it can no longer be
referenced.

However, if you refer to $Container->DataSource->f("YourField"), then
you're now referring to the data source's object, which is the field
value in the database. Doesn't matter if the object is displayed or
assigned to another object, such as a textbox or a label component. You
only have to make certain that the field is indeed selected in your data
source (ie: SELECT YourField FROM ...).

Changing your grid's Data Source from Table/View to SQL and using the
SQL CONCAT() function is one way to skin the cat, however it does
require you to change your Data Source from the nice Visual Query to the
structured query language. I personally like to save that for the
complex queries that the VQB either can't do, or system efficiencies
dictate otherwise - raw SQL queries will be quicker since CCS doesn't
have to build the SQL. We're usually talking nanoseconds that no person
will ever recognize.

Take some time to read:
http://docs.codecharge.com/studio40/html/Components/ComponentsOverview.html

If you're really really bored, read the entire Component Reference Guide
located at: http://docs.codecharge.com/studio40/ComponentReference.pdf

These should get you going in the right direction.
Rocket

Posts: 45
Posted: 12/03/2010, 2:20 PM

Thankyou, that explaination really helps. Yup, onto some dry reading, no other plans for the weekend anyway.

Cheers for now.
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.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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