StrataFrame Forum

Custom Fields

http://forum.strataframe.net/Topic27561.aspx

By Terry Bottorff - 6/28/2010

The following code works and in the current data table I get the column called contestantname.





Dim sqlbuilder As New StringBuilder(255)

With sqlbuilder

.AppendLine("SELECT bbpoints.contpk, bbpoints.rodeoid, ")

.AppendLine("bbpoints.eventcd, bbpoints.bbpk, bbpoints.go, ")

.AppendLine("bbpoints.perf, bbpoints.positioninperf, bbpoints.contestantnumber, ")

.AppendLine("bbpoints.section, bbpoints.rideleft, bbpoints.stockleft, ")

.AppendLine("bbpoints.rideright, bbpoints.stockright, bbpoints.totalscore, ")

.AppendLine("bbpoints.reride1, bbpoints.reride2, bbpoints.stockbrand, bbpoints.stockname, ")

'.AppendLine("bbpoints.turnout, bbpoints.outofrodeo, contestants.membershipcd, ")

'.AppendLine("contestants.membershipnumber, contestants.contestantname ")

.AppendLine("contestants.contestantname ")

.AppendLine("FROM bbpoints INNER JOIN contestants ")

.AppendLine("ON bbpoints.contpk = contestants.contpk WHERE (Perf = 1) ")

.AppendLine("ORDER BY perf, section, PositioninPerf ")

End With



Using cmd As New SqlCommand

cmd.CommandText = sqlbuilder.ToString()

Me.FillDataTable(cmd)

End Using





But when I try adding the following code to my bbpointsbo I get the error that follows.





Protected Overrides Function GetCustomBindablePropertyDescriptors() As MicroFour.StrataFrame.Business.FieldPropertyDescriptor()

Return New MicroFour.StrataFrame.Business.FieldPropertyDescriptor() { _

New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _

"cowboy_Name", GetType(ContestantsRodeoBO))}



End Function

'''

''' The collection of required fields for the business object.

'''





BusinessFieldDisplayInEditorAttribute(), _

Description("Cowboy Name"), _

DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _

Public ReadOnly Property cowboy_Name() As String

Get

'Return MyBase.RequiredFields

If Me.CurrentDataTable.Columns.Contains("contestantname") Then

If Not TypeOf (Me.CurrentRow.Item("contestantname")) Is DBNull Then

Return CStr(Me.CurrentRow.Item("contestantname"))

Else

Return ""

End If

Else

Return ""

End If

End Get

End Property







There is a Browsable(False), _ in the above code but does not seem to appear when I preview. I think it has to do with the '<' in front.



Error:



System.NullReferenceException was unhandled by user code

Message=Object reference not set to an instance of an object.

Source=MicroFour StrataFrame Business

StackTrace:

at MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor..ctor(String PropertyName, Type PropertyOwner)

at SFCustomField.BBPointsRodeoBO.GetCustomBindablePropertyDescriptors() in C:\VSProjectsSamples2010\SFCustomField\SFCustomField\BBPointsRodeoBO.vb:line 113

at MicroFour.StrataFrame.Business.BusinessLayer.InternalGetAdditionalPropertyDescriptors()

at MicroFour.StrataFrame.Business.BusinessLayer..ctor()

InnerException:



I'm not sure what to do. I was trying to follow what Edhy and Larry had done in a previous post. But of course I am missing something. Any help would be appreciated. Thanks in advance.
By Edhy Rijo - 6/28/2010

Hi Terry,



The following code is wrong:



Protected Overrides Function GetCustomBindablePropertyDescriptors() As MicroFour.StrataFrame.Business.FieldPropertyDescriptor()

Return New MicroFour.StrataFrame.Business.FieldPropertyDescriptor() { _

New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _

"cowboy_Name", GetType(ContestantsRodeoBO))}

End Function





The GetType should reference the current BO in which the Custom Field Property is being created, so it should be:



Protected Overrides Function GetCustomBindablePropertyDescriptors() As MicroFour.StrataFrame.Business.FieldPropertyDescriptor()

Return New MicroFour.StrataFrame.Business.FieldPropertyDescriptor() { _

New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _

"cowboy_Name", GetType(bbpointsbo))}

End Function

By Terry Bottorff - 6/29/2010

Perfect. Thank you so much.
By Edhy Rijo - 6/29/2010

No problem Smile