Wednesday, April 10, 2013

How to Bind Select2 Jquery in MVC

Action
------------------
Public ActionResult Author()
{
     SelectList Newterms = null;
            IEnumerable Author = AuthorList.AsEnumerable().Select(c => new SelectListItem()

           {
               Text = objauth.ReplaceTagValueToTerm(c.TagValue, c.Term),
               Value = c.Id.ToString(),
               Selected = true,
           });
           Newterms = new SelectList(Author, "Value", "Text");
            ViewBag.NewTerms = Newterms;

}
}

-------------------------------------------------------------------------------------
View Page
    @Html.DropDownList("NewTerms", (SelectList)ViewData["NewTerms"], new { @class = "NewCssdropdown" })


--------------------------------------------------------------------------------------
Jquery


---------------------------------------------------------------------------------------------





HAPPY CODING

No comments:

Post a Comment