Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
3
Reply
how to fill dropdown from database in jqgrid in mvc??
dipti prasad
Dec 24 2014 7:57 AM
9k
Hello Friends,
Please help me in jqgrid.
how to add dynamic dropdownlist in jqgrid in add dilogue box ??
my code is working like in controller my data is come from database but not display in dropdownlist.
My View ....................
{
name: "Per", index: 'Code', align: "right", sortable: true, editable: true, edittype: 'select', editrules: { required: true }, formoptions: { rowpos: 5, colpos: 2 },
editoptions: {
dataUrl: '/Sales/Category'
, buildSelect: function (response) {
var data = typeof response === "string" ? $.parseJSON(response.responseText) : response;
var s = "<select>";
s += '<option value="0"></option>';
$.each(data, function () {
s += '<option value="' + data.Code + '">' + data.Name + '</option>';
})
return s + '</select>';
}
}, editrules: { required: true }
},// multiple: true,
....................................................................................................................................................
My Controller code
public JsonResult Category()
{
TFAT_WEBERPEntities ctx = new TFAT_WEBERPEntities();
List<string> listSelectListItems = new List<string>();
var company = from name in ctx.TfatComps select name.Name;
listSelectListItems.AddRange(company.Distinct());
ViewData["Per"] = new SelectList(listSelectListItems);
return Json(listSelectListItems, JsonRequestBehavior.AllowGet);
// return View();
}
Reply
Upload Source Code
Select only zip and rar file.
Post
Reset
Answers (
3
)
Object reference not set to an instance of an object.
how to login with youtube in asp.net and get video list