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 -> PHP

 Editable Grid: Replace Control Value Before Updating or Inserting

Print topic Send  topic

Author Message
psychlopes

Posts: 4
Posted: 02/15/2014, 10:00 AM

I have an editable grid for a taple called tapes with a control called titleID bound to a row in another table called titles.
I've set that control to hidden and created a textbox with autocomplete so that instead of a listbox, I can just type in the name of the title and either select it from the autocomplete list if it exists in the titles table or add a new record in the titles table if it doesn't exist, then enter the titleID (either existing or creating) into the tapes table.

I created a function as follows that I call from the Before Update event or Before Inset.

function SetTapeInfo()
{
global $tapes;

$dbgetTitleID = new clsDBlocal();
$getThisTitleID = CCDLookUp("titleID", "titles", "title=".$dbgetTitleID->ToSQL($tapes -> fakeTitle -> GetValue(), ccsText), $dbgetTitleID);
$getOrgTitleID = $tapes -> titleID -> GetValue();
$dbgetTitleID -> close();

if ($getThisTitleID != $getOrgTitleID)
{
$tapes -> DataSource -> titleID -> SetValue($getThisTitleID);
}
}

The problem is that it works for the insert even, but nothing changes if the rows are being updated, and the old titleID stays.
I also tried using $tapes -> titleID -> SetValue() , but I get the same result.
View profile  Send private message
eratech


Posts: 513
Posted: 02/15/2014, 5:23 PM

Not suggesting this is related, but I've had something similar when setting the 'Default value' for text boxes - they are used in Insert, but not in Update - even if there is no value in the field to be updated. In short, check if any Default Values are being used wrongly.

Otherwise, back to the good old output to see what the code is actually using
echo $tapes->fakeTitle->GetValue()

Sorry I couldn't help more.

Eric
_________________
CCS 3/4/5 ASP Classic, VB.NET, PHP
Melbourne, Victoria, Australia
View profile  Send private message
psychlopes

Posts: 4
Posted: 02/15/2014, 5:30 PM

Thanks,

I will look into that,

But for the time being I resorted to updating and inserting using a stored procedure. That took all of the guessing out of it. I pass all the controls, and I do the calculations and comparisons in the procedure. It finally works :)

But I'll still try to see if I can get that old code to work and find what the problem was, if at least to help any other person who runs into that problem.

View profile  Send private message
eratech


Posts: 513
Posted: 02/15/2014, 10:34 PM

Glad you got a solution, if not the one you expected.

I'm a fan of stored procs for multi-step processing on the DB side - I've seen too much 'drag data back to webserver to process and loop through and another lookup, and loop again....' that can be easily handled with a nice stored proc.

And they are easier to test too.

Cheers

Eric
_________________
CCS 3/4/5 ASP Classic, VB.NET, PHP
Melbourne, Victoria, Australia
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.