DataBinder.GetIndexedPropertyValue Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Retrieves the value of an indexed property.
Overloads
GetIndexedPropertyValue(Object, String) |
Retrieves the value of a property of the specified container and navigation path. |
GetIndexedPropertyValue(Object, String, String) |
Retrieves the value of the specified property for the specified container, and then formats the results. |
GetIndexedPropertyValue(Object, String)
Retrieves the value of a property of the specified container and navigation path.
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
Parameters
- container
- Object
The object reference against which expr
is evaluated. This must be a valid object identifier in the specified language for the page.
- expr
- String
The navigation path from the container
object to the public property value to place in the bound control property. This must be a string of property or field names separated by periods, such as Tables[0].DefaultView.[0].Price
in C# or Tables(0).DefaultView.(0).Price
in Visual Basic.
Returns
An object that results from the evaluation of the data-binding expression.
Exceptions
Remarks
The value of expr
must evaluate to a public property.
For any of the list Web controls, such as GridView, DetailsView, DataList, or Repeater, container
should be Container.DataItem
. If you are binding against the page, container
should be Page
.
See also
Applies to
GetIndexedPropertyValue(Object, String, String)
Retrieves the value of the specified property for the specified container, and then formats the results.
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
Parameters
- container
- Object
The object reference against which the expression is evaluated. This must be a valid object identifier in the specified language for the page.
- propName
- String
The name of the property that contains the value to retrieve.
- format
- String
A string that specifies the format in which to display the results.
Returns
The value of the specified property in the format specified by format
.
Examples
The following code example demonstrates how to use the GetIndexedPropertyValue method declaratively to bind to an indexed value.
<%# DataBinder.GetIndexedPropertyValue(Container.DataItem, "[0][0]", "{0:c}") %>
<%# DataBinder.GetIndexedPropertyValue(Container.DataItem, "[0][0]", "{0:c}") %>
Remarks
The GetIndexedPropertyValue method invokes the GetIndexedPropertyValue method, and then uses the String.Format method to format the result as specified in the format
parameter. A .NET Framework format string (like those used by String.Format) converts the Object instance returned by the data-binding expression to a String object.
Exceptions that are thrown for the GetIndexedPropertyValue method apply to the GetIndexedPropertyValue method as well.