I want to display miltiple fields in one custom FieldTemplateUserControl. For example i have property X and Y. Currently they show on separate row when i edit or insert.
Do i need to create new property to return anonymous class with just this 2 property and in custom control,read values.What about inserting? Anyone done it?
[MetadataType(typeof(EmployeeMetadata))]
public partial class Employee : INotifyPropertyChanging, INotifyPropertyChanged
{
[ScaffoldColumn(true)]
[UIHint("Point")]
public String Point
{
get
{
return new Point(this.x, this.y);
}
}
public class EmployeeMetadata
{
[ScaffoldColumn(false)]
public object x { get; set; }
[ScaffoldColumn(false)]
public object y { get; set; }
}
}
And then have point class and a Point FieldTemplate for both display and edit/insert.
UIHintPartial ClassesScaffoldColumnData Dynamic
See my blog C# Bits | Twitter @sjnaughton Always seeking an elegant solution.
Adult
Member
82 Points
44 Posts
Display multiple fields in custom FieldTemplateUserControl
Aug 27, 2008 10:14 PM|LINK
I want to display miltiple fields in one custom FieldTemplateUserControl. For example i have property X and Y. Currently they show on separate row when i edit or insert.
Do i need to create new property to return anonymous class with just this 2 property and in custom control,read values.What about inserting? Anyone done it?
Thanks
sjnaughton
All-Star
25698 Points
5169 Posts
MVP
Re: Display multiple fields in custom FieldTemplateUserControl
Aug 27, 2008 11:34 PM|LINK
As a quick idea this is what I would do:
[MetadataType(typeof(EmployeeMetadata))] public partial class Employee : INotifyPropertyChanging, INotifyPropertyChanged { [ScaffoldColumn(true)] [UIHint("Point")] public String Point { get { return new Point(this.x, this.y); } } public class EmployeeMetadata { [ScaffoldColumn(false)] public object x { get; set; } [ScaffoldColumn(false)] public object y { get; set; } } }And then have point class and a Point FieldTemplate for both display and edit/insert.UIHint Partial Classes ScaffoldColumn Data Dynamic
Always seeking an elegant solution.
scothu
Participant
1424 Points
290 Posts
AspNetTeam
Microsoft
Moderator
Re: Display multiple fields in custom FieldTemplateUserControl
Aug 28, 2008 12:18 AM|LINK
Check out the DoubleColumn sample at: http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=14473.
PM, ASP.NET Team, Microsoft