I recently try Dynamic Data on ASP.NET 3.5 Extensions CTP.
The most thing that impress me is an idea of Dynamic Control /Field.
<asp:DynamicControl runat="server" DataField="EmailAddress"/>
So you can just simple define Dynamic Field in your Grid View and it will rendered into particular template (Include Edit Template) based on data type of your value.
You can define your template to have validation control or even can you 3rd party control such as telerik.
Here is How you can tell dynamic control to render based on particular template or even BLOB/Image Type as well.
//this is a partial class to override the code which has been generated by DBML
[MetadataType(typeof(MyClassMetadata))]
public partial class MyClass
{
//TODO: You may put Validation when your data change or whatever...
}
//Here is your metadata which you will define rendering using UIHint
public class MyClassMetadata
{
//Date Type
[DisplayFormat(DataFormatString="{0:dd MMM yyyy}")]
public object StartDate {get; set;}
//Integer Type
[Range(0,10, ErrorMessage="Please enter valid quantity between 1-10")]
public object Quantity {get; set;}
//Text type using 3rd Party WSYWIG control
[UIHint("TextEditorTelerik")]
public object Description {get; set;}
//Blob - image type
[UIHint("DbImage")]
[ImageFormat(200,200)]
public object Picture {get; set;}
}
UIHint is where you define your template.
You can create whatever for your template name and just put "_Edit" for edit mode.
Just see the sample in under FieldTemplates of your Dynamic Data Project
No comments:
Post a Comment