語言

DataBinder.GetIndexedPropertyValue 方法

定義

取得索引屬性的值。

多載

名稱 Description
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。

傳回

一個由資料綁定表達式的評估所產生的物件。

例外狀況

container 是 null。

-或-

expr 是 null 空字串(“”)。

expr 不是一個有效的索引表達式。

-或-

expr 不允許索引存取。

備註

價值 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 方法本身。

另請參閱

適用於