LoadDataFromModel Method
- Namespace
TXTextControl.Web. MVC
- Package
TXTextControl.asWeb TXTextControl.from nuget.org, the private NuGet feed or Text Control Offline PackagesWeb. DocumentEditor. dll
Description
Loads a collection implementing interface System.Collections.IEnumerable as a data source.
Syntax
LoadDataFromModel(IEnumerable)
Interprets all public properties of the objects in the collection as possible table columns and / or child tables. The type of the first object in the collection is analyzed via .NET reflection and used as the basis of the assumed table structure. For more information about using object based data sources see DocumentServer.MailMerge.MergeObjects.
public TextControl LoadDataFromModel(IEnumerable model);Public Function LoadDataFromModel(model As IEnumerable) As TextControl| Parameter | Description |
|---|---|
| model | Specifies a |
LoadDataFromModel(IEnumerable, IFormatProvider)
Allows to additionally specify a format which should be applied when converting date / time values and numerical values to strings.
public TextControl LoadDataFromModel(IEnumerable model, IFormatProvider numberAndDateTimeFormat);Public Function LoadDataFromModel(model As IEnumerable, numberAndDateTimeFormat As IFormatProvider) As TextControl| Parameter | Description |
|---|---|
| model | Specifies a |
| numberAndDateTimeFormat | The format which should be applied when converting date / time values and numerical values to strings. |
Return Value
A reference to the Web.MVC.TextControl instance to allow method chaining.
Examples
The following example loads a small customer model into the server-side editor helper before the Razor view renders it.
var customers = new[]
{
new { CustomerName = "Contoso Ltd.", City = "Seattle" }
};
var configuredEditor = textControl.LoadDataFromModel(customers);
Console.WriteLine($"Configured editor: {configuredEditor.GetType().Name}");Dim customers = {
New With { .CustomerName = "Contoso Ltd.", .City = "Seattle" }
}
Dim configuredEditor = textControl.LoadDataFromModel(customers)
Console.WriteLine($"Configured editor: {configuredEditor.GetType().Name}")