Search This Blog

Saturday, November 12, 2011

ASP.NET vNEXT - Strongly Typed Data Controls

The next release of ASP.NET provides the ability to have strongly-typed data templates on data controls and introduces new property called "ModelType". This property has two expressions: Item and BindItem. And, also provides full Intellisense and compile-time checking support.

This means developers who used Eval() and Bind() helper methods to bind data into a control,

First Name: <%# Eval("FirstName") %><br />

   <asp:TextBox ID="firstName" runat="server" Text='<%# Bind("FirstName") %>' />

can use the property called "ModelType" on data controls introduced in ASP.NET vNEXT as below:

   <asp:TextBox ID="firstName" Text='<%# BindItem.FirstName %>' runat="server" />