Custom Fields


Author
Message
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Excellent! Glad that helped.
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
Many thanks for that snippet, problem solved.
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
The problem is that the user BO doesn't have the columns defined. You have two options here. Either create them via code or add them to your query to fill the user BO. The second is easier, the first is more bullet proof.

Using SQL
Just add two columns to your FillUserNames() method:

, '' As computerName
, 0 As loggedIn

This will ensure that the columns are in the data table and can be set.

Using Code
This is handled within the properties them selves. Below shows the basics (just typed in, so no promises there aren't typos/syntax errors!)
 

#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
{

  //-- Establish return var with default value set.
  string name = String.Empty;

  //-- If the column exists, get value.
  if(this.CurrentDataTable.Columns.Contains(
constComputerName))
  {
    name =
this.CurrentRow[constComputerName].ToString();
  }
  return name;
}
set
{
  //-- If the column doesn't exists, create it, using default value of type.
  if(!this.CurrentDataTable.Columns.Contains(
constComputerName))
  {
   
this.CurrentDataTable.Columns.Add(
constComputerName, typeof(string));
  }

  //-- Column is now ensured to be created and we can set value.
 
this.CurrentRow[constComputerName]= value;
}
}

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
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