DataBinder.GetIndexedPropertyValue 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
检索索引属性的值。
重载
| 名称 | 说明 |
|---|---|
| GetIndexedPropertyValue(Object, String) |
检索指定容器和导航路径的属性的值。 |
| GetIndexedPropertyValue(Object, String, String) |
检索指定容器的指定属性的值,然后设置结果的格式。 |
GetIndexedPropertyValue(Object, String)
检索指定容器和导航路径的属性的值。
public:
static System::Object ^ GetIndexedPropertyValue(System::Object ^ container, System::String ^ expr);
public static object GetIndexedPropertyValue(object container, string expr);
static member GetIndexedPropertyValue : obj * string -> obj
Public Shared Function GetIndexedPropertyValue (container As Object, expr As String) As Object
参数
- container
- Object
对其求值的对象引用 expr 。 这必须是页面的指定语言的有效对象标识符。
- expr
- String
要 container 放置在绑定控件属性中的对象到公共属性值的导航路径。 这必须是用句点分隔的属性或字段名称字符串,例如 C# 中的 Tables[0].DefaultView.[0].Price 或 Visual Basic 中的 Tables(0).DefaultView.(0).Price。
返回
一个对象,该对象由数据绑定表达式的计算结果。
例外
注解
必须 expr 计算为公共属性的值。
对于任何列表 Web 控件(如 GridView、 DetailsView、 DataList或 Repeater) container 应为 Container.DataItem。 如果要对页面进行绑定, container 应为 Page。
另请参阅
适用于
GetIndexedPropertyValue(Object, String, String)
检索指定容器的指定属性的值,然后设置结果的格式。
public:
static System::String ^ GetIndexedPropertyValue(System::Object ^ container, System::String ^ propName, System::String ^ format);
public static string GetIndexedPropertyValue(object container, string propName, string format);
static member GetIndexedPropertyValue : obj * string * string -> string
Public Shared Function GetIndexedPropertyValue (container As Object, propName As String, format As String) As String
参数
- container
- Object
对其计算表达式的对象引用。 这必须是页面的指定语言的有效对象标识符。
- propName
- String
包含要检索的值的属性的名称。
- format
- String
一个字符串,指定要在其中显示结果的格式。
返回
指定属性的值,格式由 format.
示例
下面的代码示例演示如何以声明方式使用 GetIndexedPropertyValue 方法绑定到索引值。
<%# DataBinder.GetIndexedPropertyValue(Container.DataItem, "[0][0]", "{0:c}") %>
<%# DataBinder.GetIndexedPropertyValue(Container.DataItem, "[0][0]", "{0:c}") %>
注解
该方法 GetIndexedPropertyValue 调用 GetIndexedPropertyValue 该方法,然后使用 String.Format 该方法格式化参数中指定的 format 结果。 .NET Framework 格式字符串(如 String.Format 使用的字符串)将数据绑定表达式返回的 Object 实例转换为 String 对象。
为该方法GetIndexedPropertyValue引发GetIndexedPropertyValue的异常也适用于该方法。