Взять следующий пример кода: (ASP.NET WebForms)
<asp:Content ContentPlaceHolderID="Contents" runat="server">
<div class="blogpost-list">
<asp:Repeater ID="blogList" runat="server">
<ItemTemplate>
<h2 class="blogpost-title">
<%# (Container.DataItem as BlogPost).Title %>
</h2>
<p class="blogpost-meta">
</p>
<p class="blogpost-content">
<%# (Container.DataItem as BlogPost).ParsedContent %>
</p>
</ItemTemplate>
</asp:Repeater>
</div>
</asp:Content>
Теперь то, что я хочу сделать, - это избежать приведения содержимого DataItem, т.е. эта строка:
<%# (Container.DataItem as BlogPost).Title %>
Я чувствую себя вдохновленным ASP.NET MVC, и мне было интересно, смогу ли я создать строго типизированный, просмотреть и определить его как
<%@ Page
Language="C#" MasterPageFile="~/Blog.Master"
AutoEventWireup="true" CodeBehind="Default.aspx.cs"
Inherits="MyBlog.Default<MyStrongViewType>"
%>
Или любым другим способом избежать приведения типов и, как правило, иметь строго типизированное представление для ASP.NET WebForms.
Есть хорошие идеи?