Two tables are there
1. Status_Master
2. Role Master
a. Status_Id(Identity,Primary key) a. Role_Id(Identity,Primary key)
b. Status_Desc. b. Role_Desc
c. Remarks c. Status (wants for Dropdown list)
Here Model is [Status_Master_Model] Here Model is [Role_Master_Model]
Question is in [Role_Master_Model] view i have to us Dropdown for column c i.e (Status) an d bind the value from [Status_Master_Model] for column b i.e (Status_Desc.)
Help me with codes....as i am doing in [Role_Master_Model]..[@Html.TextBoxFor(m => m.Status) ]..as stated in red one..errror is coming as [Role_Master_Model] does not contain its defination
Soumalya DasPosted Aug 7, 2016, 12:00 PM
Kunal GuptaPosted Jul 15, 2016, 5:06 AM
Kunal GuptaPosted Jul 15, 2016, 3:29 AM
Kunal GuptaPosted Jul 15, 2016, 3:28 AM
Kunal GuptaPosted Jul 15, 2016, 2:32 AM
Rajeev PunhaniPosted Jul 13, 2016, 6:54 AM
If the above solution is helpful then,accept the answer.
Kunal GuptaPosted Jul 13, 2016, 1:54 AM
Kunal GuptaPosted Jul 11, 2016, 6:02 AM
Kunal GuptaPosted Jul 11, 2016, 2:49 AM
Kunal GuptaPosted Jul 11, 2016, 2:49 AM
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using vijay_dotnet.Models;
namespace vijay_dotnet.Controllers
{
public class RoleController : Controller
{
//
// GET: /Role/
public ActionResult Role()
{
return View();
}
}
}
Kunal GuptaPosted Jul 11, 2016, 2:47 AM
@{
ViewBag.Title = "Role";
}
@using (Html.BeginForm()) {
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<table width="100%" border="1" cellspacing="2">
<tr>
<td colspan="2" ><b>Role Master</b></td>
</tr>
<tr>
<td align="right">Role Description :</td>
<td >@Html.TextBoxFor(m => m.Role_Description)</td>
</tr>
<div class="row">
<div class="col-md-3">
@Html.DisplayName("Status")
</div>
<div class="col-md-3">
@Html.DropDownListFor(model => model.Role_Id, new SelectList(Model.Status_Description, "Value", "Text"), new { @class = "form-control" })
</div>
<div class="col-md-3">
</div>
<div class="col-md-3">
</div>
<tr>
<td align="center" colspan="2">
<input type="submit" value="Save" />
</td>
</tr>
</table>
}
<div>
@Html.ActionLink("Back to List", "List")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
Kunal GuptaPosted Jul 11, 2016, 2:47 AM
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace vijay_dotnet.Models
{
public class Role_Master_Model
{
public int Role_Id { get; set; }
public string Role_Description { get; set; }
public string Status { get; set; }
public IEnumerable<SelectListItem> Status_Description { get; set; }
}
}
Rajeev PunhaniPosted Jul 11, 2016, 1:59 AM
Hi Kunal,
Please post your Modeland ViewCode.I think you are missing property from Status_Master_Model and Role_Master_Model.
kalu singh raoPosted Jul 11, 2016, 1:54 AM
Kunal GuptaPosted Jul 11, 2016, 1:23 AM
Rajeev PunhaniPosted Jul 11, 2016, 1:09 AM
Hi Kunal,
Please see the below link.