ProfileBase::Item Property
Gets or sets a profile property value indexed by the property name.
Assembly: System.Web (in System.Web.dll)
public: virtual property Object^ Item[String^ propertyName] { Object^ get (String^ propertyName) override; void set (String^ propertyName, Object^ value) override; }
Parameters
- propertyName
- Type: System::String
The name of the profile property.
| Exception | Condition |
|---|---|
| System.Configuration.Provider::ProviderException | An attempt was made to set a property value on an anonymous profile where the property's allowAnonymous attribute is false. |
| System.Configuration::SettingsPropertyNotFoundException | There are no properties defined for the current profile. -or- The specified profile property name does not exist in the current profile. -or- The provider for the specified profile property did not recognize the specified property. |
| System.Configuration::SettingsPropertyIsReadOnlyException | An attempt was made to set a property value that was marked as read-only. |
| System.Configuration::SettingsPropertyWrongTypeException | An attempt was made to assign a value to a property using an incompatible type. |
You can use this property to retrieve or set the property values of the user profile for your application by name. Returned values are typed as object and must be cast as the specific object type when retrieved. For strongly typed access to profile property values, you can access the property by name as a member of the Profile property available on each page, for example, Profile.CustomerAddress.
The following code example lists the names of the properties in the user profile by binding the Name property from the static Properties collection of SettingsProperty objects to a GridView control. The selected property value is retrieved by name using the Item collection. For an example of a Web.config file that specifies properties for the user profile, see the example provided for the ProfileBase class.
- AspNetHostingPermission
for operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.
- AspNetHostingPermission
for operating in a hosted environment. Demand value: InheritanceDemand; Permission value: Minimal.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.