If I'm honest, I am struggling. I am still not getting anything through for new_licenceid_id. I have chopped down the Bind statement only for this post. The record is being created but the Licence Is is empty
' GET: clientCRbankdata/Create
Function Create() As ActionResult
ViewBag.licenceID = "123456789"
Return View()
End Function
' POST: clientCRbankdata/Create
<HttpPost()>
<ValidateAntiForgeryToken()>
Function Create(<Bind(Include:="Id,CreatedBy_Id,CreatedBy_LogicalName,CreatedBy_Name,CreatedOn,new_licenceId_Id")> ByVal new_clientbankdata As new_clientbankdata) As ActionResult
If ModelState.IsValid Then
db.new_clientbankdata.Add(new_clientbankdata)
db.SaveChanges()
Return RedirectToAction("Index")
End If
Return View(new_clientbankdata)
End Function
view
@ModelType Test.new_clientbankdata
@Code
ViewData("Title") = "Create"
Layout = "~/Views/Shared/_Layout.vbhtml"
End Code
<h2>Create</h2>
@Using (Html.BeginForm())
@Html.AntiForgeryToken()
@<div class="form-horizontal">
<h4>new_clientbankdata</h4>
<hr />
@Html.ValidationSummary(True, "", New With {.class = "text-danger"})
<input type="hidden" name="new_licenceId_Id" value="@ViewBag.licenceID"/>
<div class="form-group">
@Html.LabelFor(Function(model) model.new_ledgerref, htmlAttributes:=New With {.class = "control-label col-md-2"})
<div class="col-md-10">
@Html.EditorFor(Function(model) model.new_ledgerref, New With {.htmlAttributes = New With {.class = "form-control"}})
@Html.ValidationMessageFor(Function(model) model.new_ledgerref, "", New With {.class = "text-danger"})
</div>
</div>
<div class="form-group">
@Html.LabelFor(Function(model) model.new_sortcode, htmlAttributes:=New With {.class = "control-label col-md-2"})
<div class="col-md-10">
@Html.EditorFor(Function(model) model.new_sortcode, New With {.htmlAttributes = New With {.class = "form-control"}})
@Html.ValidationMessageFor(Function(model) model.new_sortcode, "", New With {.class = "text-danger"})
</div>
</div>
<div class="form-group">
@Html.LabelFor(Function(model) model.new_accountnumber, htmlAttributes:=New With {.class = "control-label col-md-2"})
<div class="col-md-10">
@Html.EditorFor(Function(model) model.new_accountnumber, New With {.htmlAttributes = New With {.class = "form-control"}})
@Html.ValidationMessageFor(Function(model) model.new_accountnumber, "", New With {.class = "text-danger"})
</div>
</div>
<div class="form-group">
@Html.LabelFor(Function(model) model.new_accountname, htmlAttributes:=New With {.class = "control-label col-md-2"})
<div class="col-md-10">
@Html.EditorFor(Function(model) model.new_accountname, New With {.htmlAttributes = New With {.class = "form-control"}})
@Html.ValidationMessageFor(Function(model) model.new_accountname, "", New With {.class = "text-danger"})
</div>
</div>
<div class="form-group">
@Html.LabelFor(Function(model) model.new_reference, htmlAttributes:=New With {.class = "control-label col-md-2"})
<div class="col-md-10">
@Html.EditorFor(Function(model) model.new_reference, New With {.htmlAttributes = New With {.class = "form-control"}})
@Html.ValidationMessageFor(Function(model) model.new_reference, "", New With {.class = "text-danger"})
</div>
</div>
<div class="form-group">
@Html.LabelFor(Function(model) model.new_defaultvalue, htmlAttributes:=New With {.class = "control-label col-md-2"})
<div class="col-md-10">
@Html.EditorFor(Function(model) model.new_defaultvalue, New With {.htmlAttributes = New With {.class = "form-control"}})
@Html.ValidationMessageFor(Function(model) model.new_defaultvalue, "", New With {.class = "text-danger"})
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</div>
</div>
End Using
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@Section Scripts
@Scripts.Render("~/bundles/jqueryval")
End Section