asp.net - Container.DataItem 到底是什么?

标签 asp.net

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#.

关于asp.net - Container.DataItem 到底是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3999109/

相关文章:

c# - SQL Server 存储过程返回值,并在 C# 中使用

c# - 如果我不需要支持特定于语言环境的变体,我可以仅使用 zh-Hans/zh-Hant resx 文件来表示中文吗?

css - 在页面所有不包含控件的部分设置网页背景图片

c# - 从带有波浪号 (~) 符号的 URL 获取完整 URL

c# - 自定义 httphandler 在重写路径时抛出异常

asp.net - 将网站特定的 ConnectionString 与 DLL 结合使用

Asp.net mvc bundle 。结合起来效果很好。但压缩和缩小不起作用

c# - 无法获取 TextBox 值 OnRowUpdating

asp.net - 如何预热 ASP.NET Web 应用程序,以便导航到时启动时间不会太长?

c# - 为我自己的类库创建选项类