System.Web.Profile.ProfileBase.SetPropertyValue C# (CSharp) Method

SetPropertyValue() public method

public SetPropertyValue ( string propertyName, object propertyValue ) : void
propertyName string
propertyValue object
return void
		public void SetPropertyValue (string propertyName, object propertyValue)
		{
			if (!_propertiyValuesLoaded)
				InitPropertiesValues ();

			if (_propertiyValues [propertyName] == null)
				throw new SettingsPropertyNotFoundException ("The settings property '" + propertyName + "' was not found.");

			if (!(bool)((SettingsPropertyValue) 
				_propertiyValues [propertyName]).Property.Attributes["AllowAnonymous"] && IsAnonymous)
				throw new ProviderException ("This property cannot be set for anonymous users.");

			((SettingsPropertyValue) _propertiyValues [propertyName]).PropertyValue = propertyValue;
			_dirty = true;
			_lastActivityDate = DateTime.UtcNow;
			_lastUpdatedDate = _lastActivityDate;
		}

Usage Example

 protected void Save_Click(object sender, EventArgs e)
 {
     objProfileBase = ProfileBase.Create(User.Identity.Name);
     //insert profile information of user
     objProfileBase.SetPropertyValue("PriceRate", txtPrice.Text);
     objProfileBase.SetPropertyValue("Discount", txtDiscount.Text);
     objProfileBase.SetPropertyValue("Tax", txtTax.Text);
     objProfileBase.Save();
     lblMsg.Style.Add("Color","green");
     lblMsg.Text = "Price Rate Settings Updated Successfully.";
 }
All Usage Examples Of System.Web.Profile.ProfileBase::SetPropertyValue