﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » Business Objects and Data Access (How do I?)  » Seting Default Values</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Wed, 27 May 2026 11:36:12 GMT</lastBuildDate><ttl>20</ttl><item><title>Seting Default Values</title><link>http://forum.strataframe.net/FindPost7233.aspx</link><description>I have a BO with a lot of fields that need to set with defaults, I also have a datatable with the field name and value. Is there a way to set these defaults looping thru the data table&amp;nbsp;without having to&amp;nbsp;use a select case where i must type Case datatable.fieldname = me.fieldname. For example in vfp one could use macro &lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #1f5080; FONT-FAMILY: Verdana"&gt;substitution , but not in vb.net or c sharp.net&lt;/SPAN&gt;</description><pubDate>Tue, 20 Mar 2007 09:18:52 GMT</pubDate><dc:creator>Bradley Marston</dc:creator></item><item><title>RE: Seting Default Values</title><link>http://forum.strataframe.net/FindPost7599.aspx</link><description>Yes, the constructor for the BrokenRule class is internal (Friend in VB), to prevent broken rules from being added outside of the business objects themselves.&amp;nbsp; If you want to be able to add a broken rule from outside of a business object, then you'll need to create a public method that will turn around and call the BusinessLayer.AddBrokenRule method internally.</description><pubDate>Tue, 20 Mar 2007 09:18:52 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Seting Default Values</title><link>http://forum.strataframe.net/FindPost7598.aspx</link><description>For one last question on the subject , how do&amp;nbsp;I add a broken rule to a created business object. for example &lt;P&gt;BOCustomers&lt;FONT size=2&gt;.BrokenRules.Add()&amp;nbsp; takes a parameter of type &lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT size=2&gt;MicroFour.StrataFrame.Business.BrokenRule&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT size=2&gt;When&amp;nbsp;I try to create an object of&amp;nbsp;MicroFour.StrataFrame.Business.BrokenRule&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT size=2&gt;&amp;nbsp;I cannot use the new keyword, and all the relevent properties seem to be &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT size=2&gt;Read Only.&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;</description><pubDate>Tue, 20 Mar 2007 09:02:45 GMT</pubDate><dc:creator>Bradley Marston</dc:creator></item><item><title>RE: Seting Default Values</title><link>http://forum.strataframe.net/FindPost7461.aspx</link><description>Yes, there is an overload to accept the field name as a string. &amp;nbsp;The overload to accept the parameter as an enum (which is defined within the partial class of the business object) just .ToString()s the enum value and calls the other overload.&amp;nbsp; So, you can certainly make it dynamic, and also add broken rules for custom properties that do not have a value in the enum.</description><pubDate>Wed, 14 Mar 2007 08:41:23 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Seting Default Values</title><link>http://forum.strataframe.net/FindPost7460.aspx</link><description>On a related note is there a way to&amp;nbsp;similarly add BrokenRules without having to hardcode the first parameter and make&lt;P&gt;it dynamic? &lt;/P&gt;&lt;P&gt;Me.AddBrokenRule(&lt;U&gt;MyBusinessObjectFieldNames.cust_lname&lt;/U&gt;, "Last name must be at least two characters.")&lt;/P&gt;&lt;P&gt;becomes &lt;/P&gt;&lt;P&gt;dim myvalue as string = "cust_lname" &lt;/P&gt;&lt;P&gt;Me.AddBrokenRule(myvalue , "Last name must be at least two characters.")&lt;BR&gt;&lt;/P&gt;&lt;P&gt;&lt;BR&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR&gt;&amp;nbsp;</description><pubDate>Wed, 14 Mar 2007 08:32:20 GMT</pubDate><dc:creator>Bradley Marston</dc:creator></item><item><title>RE: Seting Default Values</title><link>http://forum.strataframe.net/FindPost7258.aspx</link><description>After I posted the question&amp;nbsp;I thought there would be a way to do it using current row, but did not have the time to investigate it. Your reponse is very much apprecited and will save me a lot of time.</description><pubDate>Fri, 02 Mar 2007 07:53:13 GMT</pubDate><dc:creator>Bradley Marston</dc:creator></item><item><title>RE: Seting Default Values</title><link>http://forum.strataframe.net/FindPost7239.aspx</link><description>Yeah...as you already know, macros were a very dangerous thing since it was not strong-typed, but also a useful tool when you just want to "strong-arm" something.&amp;nbsp; In .NET, you will use reflection.&amp;nbsp; However, in this example you can just use the CurrentRow exposed on the BO.&lt;/P&gt;&lt;P&gt;[codesnippet]Dim loRow As DataRow&lt;/P&gt;&lt;P&gt;For Each loRow IN MyTempDataTable.Rows&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyBO.CurrentRow.Item(loRow.Item("FieldName")) = loRow.Item("FieldValue")&lt;BR&gt;Next[/codesnippet]</description><pubDate>Thu, 01 Mar 2007 11:36:35 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item></channel></rss>