惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
T
The Exploit Database - CXSecurity.com
W
WeLiveSecurity
S
Security @ Cisco Blogs
Cloudbric
Cloudbric
D
Darknet – Hacking Tools, Hacker News & Cyber Security
N
News and Events Feed by Topic
P
Privacy & Cybersecurity Law Blog
Help Net Security
Help Net Security
L
LINUX DO - 最新话题
H
Hacker News: Front Page
H
Heimdal Security Blog
Google DeepMind News
Google DeepMind News
V
Vulnerabilities – Threatpost
Know Your Adversary
Know Your Adversary
F
Fortinet All Blogs
博客园 - 三生石上(FineUI控件)
Recorded Future
Recorded Future
阮一峰的网络日志
阮一峰的网络日志
T
Tor Project blog
D
DataBreaches.Net
V
Visual Studio Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Stack Overflow Blog
Stack Overflow Blog
GbyAI
GbyAI
Recent Commits to openclaw:main
Recent Commits to openclaw:main
aimingoo的专栏
aimingoo的专栏
The Hacker News
The Hacker News
A
Arctic Wolf
大猫的无限游戏
大猫的无限游戏
月光博客
月光博客
P
Proofpoint News Feed
T
Tailwind CSS Blog
Apple Machine Learning Research
Apple Machine Learning Research
WordPress大学
WordPress大学
Scott Helme
Scott Helme
酷 壳 – CoolShell
酷 壳 – CoolShell
SecWiki News
SecWiki News
The Cloudflare Blog
N
News and Events Feed by Topic
宝玉的分享
宝玉的分享
Hacker News - Newest:
Hacker News - Newest: "LLM"
小众软件
小众软件
博客园 - Franky
人人都是产品经理
人人都是产品经理
J
Java Code Geeks
Blog — PlanetScale
Blog — PlanetScale
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Attack and Defense Labs
Attack and Defense Labs
T
Threat Research - Cisco Blogs

博客园 - Bēniaǒ

简化工作流程,10款必备的HTML5开发工具 Bing Maps开发扩展三:Bing Maps中渲染ESRI SHP空间数据 Bing Maps开发扩展二:基于Oracle Spatial的空间数据分析 Flash中各种图形的绘制 产品管理,明天会如何发展? 产品经理的34个感想 Bing Maps开发扩展一:Oracle Spatial的空间数据渲染 DeepEarth自定义图元的中心位置纠偏 研发管理:产品研发团队的早会 中国式产品管理,探索中前行 Bing Maps WPF Control SQL Server 2008空间数据应用系列十二:Bing Maps中呈现GeoRSS订阅的空间数据 SQL Server 2008空间数据应用系列十一:提取MapInfo地图数据中的空间数据解决方案 【动画技巧】GIF动画转SWF小技巧 【动画技巧】在Flash中自定义鼠标外观 SQL Server 2008空间数据应用系列十:使用存储过程生成GeoRSS聚合空间信息 Bing Maps Android SDK Released SQL Server 2008空间数据应用系列九:使用空间工具(Spatial Tools)导入ESRI格式地图数据 SQL Server 2008空间数据应用系列八:基于Bing Maps(Silverlight)的空间数据存储
ASP.NET 4.5新特性一:强类型数据绑定(Strongly-Type Data-Bindings)
Bēniaǒ · 2012-03-08 · via 博客园 - Bēniaǒ

  随着ASP.NET 4.5的发布提供了很多的新特性,其中强类型数据绑定(Strongly-Type Data-Bindings)为我们的开发非常便利,且使用率非常之高,本篇博文和大家一起学习分享这一新特性,欢迎大家拍砖。

  首先回顾一下老式的数据绑定方式,比如需要将数据绑定到Repeater控件,通常会采用如下的实现方式。

<ul>
    <asp:Repeater ID="Repeater1" runat="server">
        <ItemTemplate>
            <li>
                <%Eval("FirstName"%>
                <%Eval("LastName"%>
            </li>
        </ItemTemplate>
    </asp:Repeater>
</ul>

  后台数据绑定方式不变,沿用DataSource提供数据源和DataBind()。

protected void Page_Load(object sender, EventArgs e)
{
    using (var db = new WebFormsLab.Model.ProductsContext())
    {
        this.customersRepeater.DataSource = db.Customers.ToList();
        this.customersRepeater.DataBind();
    }
}

  在ASP.NET 4.5中提供了强类型数据绑定新特性,通过控件的ModelType指定要绑定的强类型对象全限定名,提供了新的数据绑定表示式<%#: Item.属性 %>,如上的Repeater控件的数据绑定采用新特性的实现如下代码块。

<ul>
    <asp:Repeater ID="customersRepeater" ModelType="WebFormsLab.Model.Customer" runat="server">
        <ItemTemplate>
            <li>
                <%#: Item.FirstName %>
                <%#: Item.LastName %>
            </li>
        </ItemTemplate>
    </asp:Repeater>
</ul>

  详细请访问:http://www.asp.net/vNext