Hi dharmendr,
I had followed your code, i passing one string in this list.
In Controller
List<string> AuthorList = new List<string>();
foreach (var RightsList in Rights)
{
AuthorList.Add(RightsList.Rights);
}
ViewData["Options"] = (AuthorList);
In View:
var commasep = [];
var array = @Html.Raw(Json.Encode(ViewData["Options"] as List<string>));
for (var i = 0; i < array.length; i++) {
commasep[i] = array[i];
alert(commasep[i]);
}
var times = (commasep).join(",");
alert(times);
and binding the same to dropdownlist , via your way.
data: null,
"render": function (d, t, r) {
var $select = $("<select></select>", {
"id": "drpMasterRights",
"value": d
});
$.each((times), function (k, v) {
var $option = $("<option></option>", { "text": v, "value": v });
if (d.Rights === v) {
$option.attr("selected", "selected")
}
$select.append($option);
});
return $select.prop("outerHTML");
}
but in dropdown it is binding as letters, instead of words.
it is looking as
v
i
e
w,
E
d
i
t.
I need to bind as
View
Edit
No Access.
In times variable, it is coming as View, Edit, No Access.
Kindly help on this.
Thank you.