D
Dirk
Hello,
I have a problem to use databinding with my business layer classes. My
data class does not have simple properties (string, int or datetime),
instead, all my properties are objects of the generic type Field<T>
(see sample code).
public class Employee
{
public Field<string> Forename
{
get
{
if(m_Forename == null)
m_Forename = new Field<string>(....);
return m_Forename;
}
}
public Field<string> Lastname
{
get
{
if(m_Lastname == null)
m_Lastname= new Field<string>(....);
return m_Lastname;
}
}
// The Employee class has many more properties with the Field<T>
datatype.
}
public class Field<T>
{
public T CurrentValue
{
get
{
// Get Field from database...
return ...;
}
set
{
// Save Value in Database
// Save last change date.
// Save NT-Username of the User who made the last changes
}
}
public DateTime LastChangeDate
{
get
{
return ...;
}
}
public string LastChangeUserName
{
get
{
return ...;
}
}
// I have some more informations for each Field...
}
When I now try to use databinding of a collection of those objects to
da grid (I use the Janus GridEx, but the problem is a general
databinding problem), I have the problem that the databinding
expression only accepts one-level-property names "Forename". What I
need is something like "Forename.CurrentValue", but that is not
possible.
I know that it would be possible to add every Property in the Employee
class twice like
public string FornameValue
{
get
{
return this.Forname.CurrentValue;
}
}
But this is a ugly solution.
Does anyone have an idea how I can change the Field<T> class so that I
can use it with Databinding?
Regards
Dirk
I have a problem to use databinding with my business layer classes. My
data class does not have simple properties (string, int or datetime),
instead, all my properties are objects of the generic type Field<T>
(see sample code).
public class Employee
{
public Field<string> Forename
{
get
{
if(m_Forename == null)
m_Forename = new Field<string>(....);
return m_Forename;
}
}
public Field<string> Lastname
{
get
{
if(m_Lastname == null)
m_Lastname= new Field<string>(....);
return m_Lastname;
}
}
// The Employee class has many more properties with the Field<T>
datatype.
}
public class Field<T>
{
public T CurrentValue
{
get
{
// Get Field from database...
return ...;
}
set
{
// Save Value in Database
// Save last change date.
// Save NT-Username of the User who made the last changes
}
}
public DateTime LastChangeDate
{
get
{
return ...;
}
}
public string LastChangeUserName
{
get
{
return ...;
}
}
// I have some more informations for each Field...
}
When I now try to use databinding of a collection of those objects to
da grid (I use the Janus GridEx, but the problem is a general
databinding problem), I have the problem that the databinding
expression only accepts one-level-property names "Forename". What I
need is something like "Forename.CurrentValue", but that is not
possible.
I know that it would be possible to add every Property in the Employee
class twice like
public string FornameValue
{
get
{
return this.Forname.CurrentValue;
}
}
But this is a ugly solution.
Does anyone have an idea how I can change the Field<T> class so that I
can use it with Databinding?
Regards
Dirk