Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Business object rule validation
Message
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Environment versions
Environment:
C# 2.0
OS:
Windows Server 2003
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01326989
Message ID:
01327249
Views:
11
This message has been marked as the solution to the initial question of the thread.
Linda,

>I am validating a foreign key entered in a text box. I already have a rule created by the business layer generator for a required entry. Now I want to make sure that the number matches a row in the foreign table. I would like some advice on best practice here. Currently, I have modified that validation rule to add code to check for a valid entry.
>
>
>                int PatientCount = ExecuteScalar("SELECT COUNT(*) FROM Patient WHERE ClientPatientId = '" + ClientPatientId + "'");
>                if (PatientCount = 0)
>                {
>                    Msg = "Unable to locate this patient.";
>                    AddErrorProviderBrokenRule("ClientPatientId", Msg);
>                }
>
>
>If it is valid, I want to look up and display some related fields. I was thinking that I could use the event,
>txtClientPatientId_TextChanged(object sender, EventArgs e), and have it call the foreign business object. The only problem is that it fires after each letter entered, doesn't it? Is this a reasonable approach to doing this? Is there a better solution?

The best place to put this code is in an event handler for the control's Validating event rather than TextChanged.
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform