I Just want to know how i can set a deafault category in my project .
Here is the Controller :
public ActionResult Create()
{
var ii = User.Identity.GetUserId();
ViewBag.User_ID = ii;
ViewBag.Category_id = new SelectList(db.Categories, "Category_id", "Category_name");
return View();
}
View:
<div class="form-group">
<h4>@Html.LabelFor(model => model.Category_id, htmlAttributes: new { @class = "control-label col-md-3" })</h4>
<div class="col-md-6">
@Html.DropDownList("Category_id", null, htmlAttributes: new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Category_id, "", new { @class = "text-danger" })
</div>
</div>
How to make a specific category id or name as default category in the list . Thanks