I am using ASP.NET Dynamic Data and one thing I would like to do is to have a meta class, for example:
public class CopyTermsHolidaysMetadata
{
[Required]
public int SchoolID { get; set; }
[Required]
[UIHint("AcademicYear")]
public int AcademicYear { get; set; }
[DisplayName("Recipient School")]
[Required]
public int DestinationSchoolID { get; set; }
}
Now, the two field SchoolID and DestinationSchoolID are drop down lists which come from the "School" table.
Is there any attribute which I can use to automatically populate these as the drop down lists that they are?
You should use FilterUIHintAttribute
class that allows to replace (or add new filters) default filters on the CopyTermsHolidays
entity.
For example:
[Required]
[UIHint("AcademicYear")]
[FilterUIHint("AcademicYearFilter")]
public int AcademicYear { get; set; }
where AcademicYearFilter
is custom filter which need to be located in ~\\DynamicData\\Filters
directory ( AcademicYearFilter.ascx
).
More information at FilterUIHintAttribute Class .
I will take courage to attach to my answer filter template lookup algorithm and some
citation from ASP.NET Dynamic Data UNLEASHED :
Compared to the lookup rules for field templates, lookup rules for filter templates are simple. Dynamic Data uses only the FilterUIHint associated with the column and has an intrinsic knowledge of several column types. If the FilterUIHint is not specified in the data model, and the column is Foreign Key (a column that represents the parent navigation property of a many-to-one or a one-to-one association in the child entity), a Boolean, or an enumeration, Dynamic Data chooses a predefined FilterUIHint value, ForeignKey, Boolean, or Enumeration, respectively. Having the FilterUIHint value, Dynamic Data tries to locate a user control with the matching name in the DynamicData\\Filters directory of the web application project. If the user control does not exist, the lookup process ends, and filtering is considered to be unsupported for this column.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.