---
title: "How to Bind textbox to Model?"  
description: "How to Bind textbox to Model?"  
author: "Gaurpriya Bishnoi"  
published: 2015-07-07  
updated: 2015-07-09  
canonical: https://www.mindstick.com/forum/23324/how-to-bind-textbox-to-model  
category: "asp.net mvc"  
tags: ["mvc4", "model"]  
reading_time: 2 minutes  

---

# How to Bind textbox to Model?

```
foreach (var item in Model){    <tr>      <td class="well"> @Html.TextBoxFor(m => item.UserMaster.D1, new { @class = "form-control" })</td>     <td class="well"> @Html.TextBoxFor(m => item.UserMaster.D2, new { @class = "form-control" })</td>     <td class="well"> @Html.TextBoxFor(m => item.UserMaster.D3, new { @class = "form-control" })</td>     <td class="well"> @Html.TextBoxFor(m => item.UserMaster.D4, new { @class = "form-control" })</td>     <td class="well"> @Html.TextBoxFor(m => item.UserMaster.D5, new { @class = "form-control" })</td>     <td class="well"> @Html.TextBoxFor(m => item.UserMaster.D6, new { @class = "form-control" })</td>     <td class="well"> @Html.TextBoxFor(m => item.UserMaster.D7, new { @class = "form-control" })</td>     <td class="well"> @Html.TextBoxFor(m => item.UserMaster.D8, new { @class = "form-control" })</td>    </tr>}
```

\
I am want to make these [textbox](https://www.mindstick.com/forum/12714/dynamic-textbox-in-gridview) inside [for loop](https://www.mindstick.com/forum/12568/android-for-loop-not-working-in-main-thread) how to possible\
\

## Replies

### Reply by Anonymous User

Hi GaurpriyaStep 1:Create a class public class FieldList { public string Name { get; set; } }Step 2:Add Property in your model public IList<FieldList> UserMaster { get; set; }\
Step 3:Use this code in your razor page. @for (int a = 0; a <= 10; a++) { @Html.EditorFor(m => m.UserMaster[a].Name); }\
\

### Reply by Gaurpriya Bishnoi

Hi Mayank \
i am want to simple these textbox make inside for loop\
foreach (var item in Model){ for(int i=0;i<15;i++) { <tr> <td class="well"> @Html.TextBoxFor(m => item.UserMaster.D1, new { @class = "form-control" })</td> </tr> }}\

But i am face problem in model binding \
In above code every textbox is bind same column name (D1). \
But i am want to every textbox is bind different different column like(D1, D2, D3)...etc \
please solve this problem as soon soon

### Reply by Anonymous User

Hi Gaurpriya please explain this a bit more so that we can analyse the issue and implement it


---

Original Source: https://www.mindstick.com/forum/23324/how-to-bind-textbox-to-model

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
