如何绑定 List<Int>到网格视图? [英] How to bind a List<Int> to a gridview?
问题描述
这可能是一个很奇怪的问题,因为通常人们只将复杂类型绑定到 gridview.但我需要绑定一个 Int 列表(字符串也是如此).通常,由于要绑定的属性使用对象的属性名称,但是当使用 Int 或 String 时,值正是对象本身,而不是属性.
This might be quite a strange question since usually people bind only complex types to a gridview. But I need to bind a List of Int (the same is for strings). Usually, as the property to bind one uses the name of the property of the object, but when using a Int or a String, the value is exactly the object itself, not a property.
获取对象值的名称"是什么?我试过价值"、"(空)、这个"、项目",但没有运气.
What is the "name" to get the value of the object? I tried "Value", "" (empty), "this", "item" but no luck.
我指的是网络表单中的 gridview.
I'm referring to a gridview in a web form.
更新
有一个相关的 Stack Overflow 问题,如何绑定一个列表到一个 GridView.
There's a related Stack Overflow question, How to bind a List to a GridView.
推荐答案
BoundField.ThisExpression
等于!").
<BoundField DataField="!" />
may do the trick (since BoundField.ThisExpression
equals "!").
这篇关于如何绑定 List<Int>到网格视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!