Attached with this post is zip file having multiple files which provides functionality of adding default values to Business Object automatically, it works in this way :-
1. Add the Tables as specified in Attachment, In short you will store :-
BO Name :- Order
Property Name :- Customer
& Value to Be set :- Xyz Co.
Also add the related stored procedure as specified.
2. Do the changes in your business Object as specifed.
Once these changes are done and new object is created, it will set up a namevaluelist based class to default values for a particular object. Generic routines are provided which loops through all the properties in the list and sets business object properties with appropriate default values.
Advantage of using this is less code and one time only you can retreive the default value list from database and can create objects with default values without using database connection.
pls try this and advise your comments/feedback.
Thanks for your comments.
Kindly note that i will complete the code to support lists, combo boxes etc. and post it here.
I beleive for putting it on CSLAContrib, we need Permission from Rocky, so i will send this by email to him also so he can decide and advise his comments.
You are correct. i will rectify the code. Also i have changed the code to be more generic
If mDefaultValueList Is Nothing ThenmDefaultValueList = DefaultValueList.GetList(TypeName(
Me)) End IfLibrary.Utilities.SetDefaultValues(
Me, mDefaultValueList)Additionally SetDefaultValues is also converted to Sub i/o Function, i will be posting final code with combobox support soon.
I missed one point here.
I think new constructor will be called in all cases i.e. if you have dataportal create with parameter or without parameter, so putting code in new will take care of all overloads..
pls correct me if I'm wrong...
Updated code is uploaded in below given post
Copyright (c) Marimer LLC