@model string
<div class="main">
    <form class="form-horizontal form">
        @foreach (var dr in ViewBag.field.Rows)
        {
            if (dr["value_type"].ToString() == "ntext")
            {
                <div class="control-group">
                    <label class="control-label">@dr["name"].ToString()</label>
                    <div class="controls form-inline form-group-sm">
                        <textarea class="form-control assignment" id="@dr["name"].ToString()" name="@dr["name"].ToString()" style="width:90%;height:300px;"></textarea>
                        <span class="help-block"></span>
                    </div>
                </div>
            }
            else
            {
                <div class="control-group">
                    <label class="control-label">@dr["name"].ToString()</label>
                    <div class="controls form-inline form-group-sm">
                        <input type="text" class="form-control assignment" id="@dr["name"].ToString()" name="@dr["name"].ToString()" style="width:90%;"/>
                        <span class="help-block"></span>
                    </div>
                </div>
            }

        }
    </form>
</div>

<script type="text/javascript">
    var json = @Html.Raw(ViewBag.Test)
    $(function () {
        $(".assignment").each(function () {
            var id = $(this).attr("id");
            $("#" + id).val(eval("json[0]." + id))
        })
    })
</script>
