I want to use Multi-Select from Dropdown.
How it Possible ?
#My View Code:
@using System.Data
@using Newtonsoft.Json
@model FTSSolution.Models.Released_Employee
@{
ViewBag.Title = "Create";
DataTable tbl = (DataTable)ViewBag.UserDetails;
//EnumerableRowCollection rows = from user in tbl.AsEnumerable()
// where user.Field("empid") == Model.empID
// select user;
//DataRow dr = (DataRow)rows.FirstOrDefault();
}
@using (Html.BeginForm())
{
@*
@Html.ValidationMessage("CustomError")
*@@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
@Html.ValidationMessage("CustomError")
@Html.ActionLink("Back to Index", "Index", "", new { @class = "btn btn-info btn-block" })
@**@
Released Employee - Entry
@Html.DropDownList("empID", new SelectList(ViewBag.UserList, "Id", "Name"), new { @Id = "ddlUser", @class = "form-control btn-block", @onchange = "userDetails()" })
@Html.ValidationMessageFor(model => model.empID) (Here I Want use multi select for EmpID)
@Html.Hidden("empCode", new SelectList(ViewBag.UserList, "Id", "Name"), new { @Id = "ddlUser", @class = "form-control btn-block", @onchange = "userDetails()",style = "display:none;" })
@Html.ValidationMessageFor(model => model.empCode)
@*@Html.TextBoxFor(model => model.dtJoin, new { @placeholder = "Joining Date", @class = "form-control", @id = "datepicker" })
@Html.ValidationMessageFor(model => model.dtJoin)*@
@*@Html.Label(@dr["CatName"].ToString(), new { @ID = "dtJoin" })*@
@*@Html.TextBoxFor(model => model.dtJoin, new { @placeholder = "Joining Date", @class = "form-control", @id = "datepicker" })
@Html.ValidationMessageFor(model => model.dtJoin)*@
@Html.TextBoxFor(model => model.dtReleased, new { @placeholder = "Released Date", @id = "datepicker1", @class = "form-control" })
@Html.ValidationMessageFor(model => model.dtReleased)
@Html.TextBoxFor(model => model.Remarks, "", new { @class = "form-control btn-block" })
@Html.ValidationMessageFor(model => model.Remarks)
@*@Html.TextBoxFor(model => model.CardNo, "2", new { @class = "form-control btn-block", style = "display:none;" })
@Html.TextBoxFor(model => model.dtJoin, "2", new { @class = "form-control btn-block", style = "display:none;" })
@Html.TextBoxFor(model => model.empCode, "2", new { @class = "form-control btn-block", style = "display:none;" })*@
top: 0px; width: 100%; height: 100%; background-color: #666666; z-index: 30001;
opacity: .8; filter: alpha(opacity=70);display:none">

@Html.ActionLink("Back to List", "Index", "", new { @class = "btn btn-info btn-block" })
@**@
}
$('select').select2();
$(document).ready(function () {
$("#datepicker").datepicker({ dateFormat: 'dd-MM-yy' });
$("#datepicker1").datepicker({ dateFormat: 'dd-MM-yy' });
});
function userDetails() {
var x = $("#ddlUser").val();
var data1 = $("#ViewData").data("value");
var data = JSON.stringify(eval("(" + data1 + ")"));
var json = JSON.parse(data);
for (var i = 0; i < json.length; i++) {
if (json[i].empid == x) {
$("#Name").text(json[i].empname.toString());
$("#dtJoin").text(json[i].dtJoin.toString());
}
}
}
@*function JavascriptFunction() {
var url = '@Url.Action("PostMethod", "Home")';
$("#divLoading").show();
$.post(url, null,
function (data) {
$("#PID")[0].innerHTML = data;
$("#divLoading").hide();
});
}*@
$(".display tr").click(function () {
$(this).find(".foo").each(function () {
//alert($(this).val());
});
});
The view will be like this;
Thanks in Advance
Nazmul

Sundaram SubramanianPosted Oct 16, 2017, 7:45 AM
Nazmul BadshaPosted Oct 14, 2017, 3:35 AM
Nilesh PatilPosted Oct 14, 2017, 2:04 AM