は、私はそれが正常に動作ビューのテキストボックスを取得するにはどうすればよいですか?私のコントローラで
n個の関係にn個を作るために、この例に従うが、データベースへのペイロードを持つn個の関係からnのために私が把握し、私が行うことができます[HTTPGET]私が見たいと思っているものを表示するが、今私は私の見解にあるテキストボックスをどうやって得ることができるのか知りたければ、私のコントローラでチェックボックスを得ることができる(以下のアクションを参照)。どのようにテキストボックスを取得することができますか?私のコントローラのすべてのチェックボックス?
@using (Html.BeginForm("AgregarEmpresas", "Empleado"))
{
<fieldset>
<div class="editor-field">
<table>
<tr>
@{
int cnt = 0;
List<ITCOrganigrama.ViewModel.AsignarEmpresa> empresas = ViewBag.Empresas;
foreach (var empresa in empresas)
{
if (cnt++ % 5 == 0) {
@: </tr> <tr>
}
@: <td>
<input type="checkbox"
name="selectedEmpresa"
value="@empresa.EmpresaId"
@(Html.Raw(empresa.Assigned ? "checked=\"checked\"" : "")) />
@empresa.Nombre
<div>
@Html.LabelFor(model => empresa.cargo)
@Html.TextBoxFor(model => empresa.cargo, new { style = "width: 150px;" })
@Html.ValidationMessageFor(model => empresa.cargo)
</div>
@:</td>
}
@: </tr>
}
</table>
</div>
<p>
<input type="submit" value="Agregar" />
</p>
</fieldset>
}
私はchekbox
[HttpPost]
public ActionResult AgregarEmpresas(int? id, FormCollection formCollection, string[] selectedEmpresa)
{
}
私の最後のビューを取得アクション:編集 http://s3.subirimagenes.com:81/otros/previo/thump_7406511add1.jpg http://www.subirimagenes.com/otros-add1-7406511.html
を:
ViewModelクラス
public class AsignarEmpresa
{
public int EmpresaId { get; set; }
public string Nombre { get; set; }
public string cargo { get; set; }
public bool Assigned { get; set; }
}
私はempresaTextBoxのnullを取得します。 私は私のビューモデルでブール値と文字列を持つクラスを持っています –