locked
Display multiple fields in custom FieldTemplateUserControl RRS feed

  • Question

  • User188291263 posted

     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

    Wednesday, August 27, 2008 6:14 PM

Answers

  • User-330204900 posted

    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.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 27, 2008 7:34 PM
  • User660823006 posted

    Check out the DoubleColumn sample at: http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=14473.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 27, 2008 8:18 PM

All replies

  • User-330204900 posted

    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.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 27, 2008 7:34 PM
  • User660823006 posted

    Check out the DoubleColumn sample at: http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=14473.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 27, 2008 8:18 PM