Custom Fields


Author
Message
Ian Hammond
Ian Hammond
StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)
Group: Forum Members
Posts: 57, Visits: 277
Hi,

I am trying to populate a grid from 2 BO's by creating custom fields in the 'master' BO. My code for the custom field properties is :



#region " Custom Field Properties"

private const String constComputerName = "computerName";

private const String constLoggedIn = "loggedIn";

[
Browsable(false)]

[
BusinessFieldDisplayInEditor()]

[
Description("computerName")]

[
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]

public String computerName

{

get { return this.CurrentRow[constComputerName].ToString(); }

set { this.CurrentRow[constComputerName]= value; }

}

[
Browsable(false)]

[
BusinessFieldDisplayInEditor()]

[
Description("loggedIn")]

[
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]

public Boolean loggedIn

{

get { return (Boolean)this.CurrentRow[constLoggedIn]; }

set { this.CurrentRow[constLoggedIn] = value; }

}

#endregion



My form has the following event enabled:



private void hlsUserNamesBO1_ParentFormLoading()

{

this.hlsUserNamesBO1.FillUserNames();

this.hlsUserProfilesBO1.FillAllProfiles();

foreach (HLSUserNamesBO row in this.hlsUserNamesBO1.GetEnumerable())

{

this.hlsUserProfilesBO1.Filter= "userId = " + row.userId;

this.hlsUserNamesBO1.computerName = this.hlsUserProfilesBO1.computerName;

this.hlsUserNamesBO1.loggedIn = this.hlsUserProfilesBO1.loggedIn;

}

}



When I hit the assignment to computerName I get the exception

"Column 'computerName' does not belong to table HLSUserNames."

Can anyone please advise, many thanks
Replies
Ian Hammond
Ian Hammond
StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)StrataFrame Novice (81 reputation)
Group: Forum Members
Posts: 57, Visits: 277
Having sorted the problem with the data binding to custom fields I have come across the following issue:

On my dataview grid I have 4 columns, user name, description, computer name(custom) and logged in flag(custom)

The username,description are loaded from UserNameBO and computer name and logged in are loaded from UserProfilesBO.

I have 3 buttons Add User, Edit User, Delete User.

Edit User: This transfers control to another form that allows me to change parameters associated with the user. When I return to the calling form I reload the UserameBO to refresh the data view grid. I then get the error:

Thd following exception occurred in the DataGridView:

System.Reflection.TargetInvocationExceptions: Exception has bee thrown by the target of an invocation,-->

System.InvalidCastException: Specified cats is not valid.

at ........HLSUserNamesBO.get_loggedIn() followed by line no.

I presume this error is due the fact that the computerName and loggedIn are not being refreshed when I refresh the usernames. Could anyone throw some light on this issue, or is there some event I should be setting similar to the parentLoading.

Many thanks
Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Ian,

Not that my suggestion  will resolve the problem with the DataGrid, but unless you need to modify data in the grid itself, I would use a ListView.

StrataFrame ListView is greatly automated to handle the BO, a childForm dialog and it is very easy to setup.  The ListView can even move the record pointer in the BO if you want it to.

There are plenty of samples on how to use the ListView and also the StrataFlix sample application uses a listview and childform dialogs the way I believe you want it to.

If you want to go with the ListView and need some help, just let us know.Smile

Edhy Rijo

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Ian,

First I would reinforce Edhy's suggestion that unless you need in-place editing, a ListView is much easier to user, much lighter weight. The SF ListView also has all the goodness Edhy mentioned related to easily hooking the ListView up to ChildFormDialogs etc.

However, to address your problem, the most common cause for this is that the column doesn't have the correct value in it (i.e. it can't be cast to a boolean). I'd set a break on the line that loads the BO and then step through it, looking at the data table.  Since this works when you load it, you must be doing something a bit differently when you refresh grid.  You might also set a break in the get of the loggedIn property and see what the data table looks like (get_loggedIn is the method generated by the compiler for the get of a property).
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search