# TextControl.LoadDataFromModel Method

> Loads a collection implementing interface System.Collections.IEnumerable as a data source.

- **Product:** TX Text Control .NET Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 24.0
- **Namespace:** `TXTextControl.Web`
- **Assembly:** `TXTextControl.Web.dll`, which the TX Text Control .NET Server setup installs, for .NET Framework; in no NuGet package
- **Path:** TX Text Control .NET Server > Reference > TXTextControl.Web > TextControl.LoadDataFromModel Method
- **841 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/textcontrol/loaddatafrommodel-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/textcontrol/loaddatafrommodel-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/textcontrol/loaddatafrommodel-method/llms-full.txt

---

### Description

Loads a collection implementing interface `System.Collections.IEnumerable` as a data source.

### Syntax

#### LoadDataFromModel(System.Collections.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](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-documentserver/mailmerge/mergeobjects-method/llms-full.txt). The method returns immediately.

```csharp
public void LoadDataFromModel(System.Collections.IEnumerable model);
```

```vbnet
Public Sub LoadDataFromModel(model As System.Collections.IEnumerable)
```

| Parameter | Description |
|---|---|
| model | Specifies a `System.Collections.IEnumerable` that contains the merge data. |

#### LoadDataFromModel(System.Collections.IEnumerable, System.IFormatProvider)

Allows to additionally specify a format which should be applied when converting date / time values and numerical values to strings.

```csharp
public void LoadDataFromModel(System.Collections.IEnumerable model, System.IFormatProvider numberAndDateTimeFormat);
```

```vbnet
Public Sub LoadDataFromModel(model As System.Collections.IEnumerable, numberAndDateTimeFormat As System.IFormatProvider)
```

| Parameter | Description |
|---|---|
| model | Specifies a `System.Collections.IEnumerable` that contains the merge data. |
| numberAndDateTimeFormat | The format which should be applied when converting date / time values and numerical values to strings. |

### Examples

`LoadDataFromModel` is not exposed by the current ASP.NET Core editor helper. The following example uses `LoadDataFromModel` in the current server-side setup instead.

```csharp
var customers = new[]
{
    new { CustomerName = "Contoso Ltd.", City = "Seattle" }
};
var configuredEditor = textControl.LoadDataFromModel(customers);
Console.WriteLine($"Configured editor: {configuredEditor.GetType().Name}");
```

```vbnet
Dim customers = {
    New With { .CustomerName = "Contoso Ltd.", .City = "Seattle" }
}
Dim configuredEditor = textControl.LoadDataFromModel(customers)
Console.WriteLine($"Configured editor: {configuredEditor.GetType().Name}")
```

---

## Nearby

- **Previous:** [TextControl.LoadDataFromJsonAsync Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/textcontrol/loaddatafromjsonasync-method/llms-full.txt)
- **Next:** [TextControl.LoadDataFromModelAsync Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/textcontrol/loaddatafrommodelasync-method/llms-full.txt)
