SAMPLE FORM DESIGN WITH TEXTBOX AND DROPDOWN:MVC DOTNET

Code for view(FSRCreate.cshtml):

@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
<br /><br />
<div class="form-group">
<div class="panel panel-default" style="border-color:#a8ddeb">
<div class="panel-heading" style="background-color:#dbedf2"><b>FSR Report - Create</b></div>
<div class="panel-body" style="font-family:Verdana;font-size:11px">
<table style="width:100%">
<tr>
<!--
<td>
Drr Number
<br/>
</td>
-->
<td>
Customer Name
<br />
@Html.TextBoxFor(model => model.Customer_Name)
@Html.ValidationMessageFor(model => model.Customer_Name)
</td>
<td>
Entry Date
<br />
@Html.EditorFor(model => model.date1)
@Html.ValidationMessageFor(model => model.date1)
</td>
<td>
Site Location
<br />
@Html.EditorFor(model => model.Site_Location)
@Html.ValidationMessageFor(model => model.Site_Location)
</td>
<td>
Equipment Make
<br />
@if (ViewBag.EquipmentmakeList != null)
{
@Html.DropDownListFor(model => model.Eqp_Make, ViewBag.EquipmentmakeList as SelectList, "--Select--", new { style = "width:130px;" })
}
</td>
<td>
Site Incharge
<br />
@Html.EditorFor(model => model.Site_In_Charge_Name)
@Html.ValidationMessageFor(model => model.Site_In_Charge_Name)
</td>
</tr>
<tr>
<td>
Equipment Model
<br />
@Html.EditorFor(model => model.Eqp_Model)
@Html.ValidationMessageFor(model => model.Eqp_Model)
</td>
<td>
Site Incharge Contact
<br />
@Html.EditorFor(model => model.Site_In_Charge_Contact)
@Html.ValidationMessageFor(model => model.Site_In_Charge_Contact)
</td>
<td>
Equipment Serial Number
<br />
@Html.EditorFor(model => model.Eqp_Sr_No)
@Html.ValidationMessageFor(model => model.Eqp_Sr_No)
</td>
<td>
Date of Delivery
<br />
@Html.EditorFor(model => model.Date_of_Delivery)
@Html.ValidationMessageFor(model => model.Date_of_Delivery)
</td>
<td>
Hour Meter
<br />
@Html.EditorFor(model => model.Hour_Meter)
@Html.ValidationMessageFor(model => model.Hour_Meter)
</td>
</tr>
</table>
</div>
</div>
<div style="clear:both">
<input type="submit" value="Insert Record" class="btn btn-primary" /> <a href="/Drr" class="btn btn-success">View All Records</a>
</div>
</div>
}

Controller Code for Dropdown(FSRController.cs):

public ActionResult FSRCreate()
{
List<tblEquipmentMake> EquipmentmakeList = db.tblEquipmentMakes.ToList();
ViewBag.EquipmentmakeList = new SelectList(EquipmentmakeList, “Id”, “EquipmentMake”);

return View();

}

Leave a Reply

Your email address will not be published. Required fields are marked *