asp.net – 什么是Container.DataItem?

什么是Container.DataItem?

解决方法

This article可能会帮助您了解。引用:

So what is this expression exactly? The <%# %> means this is a
DataBinding expression and Container.DataItem is an alias for the
current item in the datasource. In other words,if you are binding to
a collection of objects Container.DataItem is the current row of that
collection.

This blog entry给出了何时使用的帮助。引用:

Container.DataItem is a runtime alias for the DataItem for this
specific item in the bound list. For a grid which displays 10 rows of
data,this is one row from the datasource. The actual type of
DataItem is determined by the type of the datasource. For example,if
the datasource is a Dataview,the type of DataItem is DaTarowView. If
the type of the datasource is an array of strings,the type of
DataItem is String. If the datasource is a collection of
strongly-typed objects (for example “Employees” objects),the type of
DataItem is Employees.

Each of these cases requires a slightly different databinding expression,with further differences between VB and C#.

相关文章

这篇文章主要讲解了“WPF如何实现带筛选功能的DataGrid”,文...
本篇内容介绍了“基于WPF如何实现3D画廊动画效果”的有关知识...
Some samples are below for ASP.Net web form controls:(fr...
问题描述: 对于未定义为 System.String 的列,唯一有效的值...
最近用到了CalendarExtender,结果不知道为什么发生了错位,...
ASP.NET 2.0 page lifecyle ASP.NET 2.0 event sequence cha...