UserControl.TryUpdateModel Method

Definition

Attempts to update the model instance by using the values from the data-bound control.

Overloads

TryUpdateModel<TModel>(TModel)

Attempts to update the model instance by using the values from the data-bound control.

TryUpdateModel<TModel>(TModel, IValueProvider)

Attempts to update the model instance using values from the value provider.

TryUpdateModel<TModel>(TModel)

Attempts to update the model instance by using the values from the data-bound control.

public virtual bool TryUpdateModel<TModel> (TModel model) where TModel : class;

Type Parameters

TModel

The type of the model object.

Parameters

model
TModel

The model instance to update.

Returns

true if the model instance was updated successfully; otherwise, false.

Remarks

The TryUpdateModel method must be invoked from inside a data-operation method of the control by using the ModelType property for data binding.

Applies to

.NET Framework 4.8.1 және басқа нұсқалар
Өнім Нұсқалар
.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

TryUpdateModel<TModel>(TModel, IValueProvider)

Attempts to update the model instance using values from the value provider.

public virtual bool TryUpdateModel<TModel> (TModel model, System.Web.ModelBinding.IValueProvider valueProvider) where TModel : class;

Type Parameters

TModel

The type of the model object.

Parameters

model
TModel

The model instance to update.

valueProvider
IValueProvider

A dictionary of values to use to update the model.

Returns

true if the model instance was updated successfully; otherwise, false.

Remarks

The TryUpdateModel method must be invoked from inside a data-operation method of the control using the ModelType property for data binding.

Applies to

.NET Framework 4.8.1 және басқа нұсқалар
Өнім Нұсқалар
.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1