Hello,
i work with DataAnnotations in my InfoClass:
when use AutoGeneratingField is my Order not correct.
my problem or has RadDataForm a problem?
i work with DataAnnotations in my InfoClass:
public
partial
class
SDLmedia_ComputerMonitor
{
internal
sealed
class
SDLmedia_ComputerMonitorMetaData
{
[Display(Order = 0, Name =
"ID:"
, Description =
"Die Indentifikation des Monitors."
)]
public
int
MonitorID {
get
;
set
; }
[Display(Order = 1, Name =
"ComputerId:"
, Description =
"Die Indentifikation des Computers."
)]
public
int
ComputerID {
get
;
set
; }
[Display(Order = 2, Name =
"Bezeichnung:"
, Description =
"Die Bezeichnung des Monitors."
)]
[Required(ErrorMessage =
"Eine Bezeichnung wird erwartet!"
)]
[StringLength(30, ErrorMessage =
"Max. 50 Zeichen!"
)]
public
string
Title {
get
;
set
; }
[Display(Order = 3, Name =
"Hersteller:"
, Description =
"Der Hersteller des Monitors"
)]
[Required(ErrorMessage =
"Hersteller wird erwartet!"
)]
[StringLength(30, ErrorMessage =
"Max. 50 Zeichen!"
)]
public
string
Manufacturer {
get
;
set
; }
[Display(Order = 4, Name =
"Typ:"
, Description =
"Um welche Art von Monitor handelt es sich(LCD,LED)."
)]
[Required(ErrorMessage =
"Monitortyp wird erwartet!"
)]
public
string
Screentype {
get
;
set
; }
[Display(Order = 5, Name =
"Display:"
, Description =
"Die Größe des Displays in Zoll."
)]
[Required(ErrorMessage =
"Displaysize wird erwartet!"
)]
[Range(10, 100, ErrorMessage =
"Displaysize sollte zwischen 10-100 Zoll liegen!"
)]
public
int
? DisplaySize {
get
;
set
; }
[Display(Order = 6, Name =
"Grafik-Port:"
, Description =
"Schnittstelle über die der Monitor angeschlossen werden kann."
)]
[Required(ErrorMessage =
"Ein Grafik-Anschluss wird erwartet!"
)]
public
string
Graphicsport {
get
;
set
; }
[Display(Order = 7, Name =
"Servicetag:"
, Description =
"Das Servicetag des Monitors."
)]
public
string
Servicetag {
get
;
set
; }
[Display(Order = 8, Name =
"Info:"
, Description =
"Informationen zu diesem Monitor."
)]
public
string
Description {
get
;
set
; }
[Display(Order = 9, Name =
"Erstellt am:"
, Description =
"Geben Sie eine Firma an."
)]
public
DateTime? CreatedDate {
get
;
set
; }
[Display(Order = 10, Name =
"Erstellt von:"
, Description =
"Geben Sie eine Firma an."
)]
public
string
CreatedByUser {
get
;
set
; }
[Display(Order = 12, Name =
"Preis:"
, Description =
"Der Preis des Monitors."
)]
[Required(ErrorMessage =
"Ein Preis wird erwartet!"
)]
public
decimal
? Price {
get
;
set
; }
}
}
when use AutoGeneratingField is my Order not correct.
private
void
DataFormMonitor_AutoGeneratingField(
object
sender, AutoGeneratingFieldEventArgs e)
{
try
{
if
(e.PropertyName.Equals(
"ComputerID"
))
{
e.DataField.Visibility = Visibility.Collapsed;
}
if
(e.PropertyName.Equals(
"MonitorID"
))
{
e.DataField.IsEnabled =
false
;
}
if
(e.PropertyName.Equals(
"Screentype"
))
{
e.DataField =
new
DataFormComboBoxField
{
Label =
"Type:"
,
ItemsSource = Monitortypes.GetMonitortypes(),
DisplayMemberPath =
"Name"
,
SelectedValuePath =
"Value"
,
DataMemberBinding =
new
Binding(
"Screentype"
) { Mode = BindingMode.TwoWay }
};
}
if
(e.PropertyName.Equals(
"Graphicsport"
))
{
e.DataField =
new
DataFormComboBoxField
{
Label =
"Anschluss:"
,
ItemsSource = Grafikports.GetGrafikports(),
DisplayMemberPath =
"Name"
,
SelectedValuePath =
"Value"
,
DataMemberBinding =
new
Binding(
"Graphicsport"
) { Mode = BindingMode.TwoWay }
};
}
if
(e.PropertyName.Equals(
"DisplaySize"
))
{
}
if
(e.PropertyName.Equals(
"Price"
))
{
e.DataField.DataMemberBinding =
new
Binding(
"Price"
) { Mode = BindingMode.TwoWay, StringFormat =
"{0:C}"
};
}
}
catch
(Exception exc)
{
Error.CreateNew(exc, ErrorTitle);
}
}
my problem or has RadDataForm a problem?