StrataFrame Forum

cannot access this.Item in BO in c#

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

By Rob Toyias - 8/9/2007

I'm trying to create a Custom Field.  I've created the public field in the BO, it will be filled by a stored procedure that joins accross tables.  I saw this done (today actually, thanks Trent!) where the filled value was accessed in the getter using Item() like so

get
{
    return Me.Item("DBColumnName");
}

problem is I'm using c#, and I don't have Item...

I use { return this.Item("DBColumnName") }
(or even Item[]) but it's not there...

I have CurrentDataTable, CurrentView, CurrentRowIndex, and CurrentRow but no Item.
I compile I get the following error:
Error 1 'BusinessObjectLib.Customers' does not contain a definition for 'Item' 

I'm thinking that should be in there, what silly thing am I doing wrong?

By StrataFrame Team - 8/10/2007

Ah, the Item property is called the Default property in VB, which translates to the this[] (indexer) property in C#.

So, you should be able to access it with:

get
{
    return this["DBColumnName"];
}

If you have a reference to a BO and you ever need to access the field, you can do the same thing:

BOType mybo = new BOType();
string value = mybo["someStringField"];

Just put the brackets directly after the reference, whether "this" or some bo variable.

By Rob Toyias - 8/10/2007

I was so close, yet so far..

thanks for the info!