Click here to Skip to main content
16,020,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys ..... I need help binding data to dropdownlist. I did this earlier using Viewbag but our database has like huge records so viewbag is not working and showing out of memory exception. Can I get other way to bind huge amount of data to dropdownlist?

What I have tried:

public ActionResult Index()

        {
            ViewBag.TPA_IPD_ITEM_TPA_CODE = m.HISWEB_TPA_IPD_ITEM_SETUP.ToList();
           ViewBag.TPA_IPD_ITEM_TPA_CODE = new SelectList(m.HISWEB_TPA_IPD_ITEM_SETUP, "TPA_IPD_ITEM_TPA_CODE", "TPA_IPD_ITEM_TPA_CODE");

            return View();



<div class="form-group">
                @Html.LabelFor(model => model.TPA_IPD_ITEM_TPA_CODE, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-4">
                     @Html.DropDownList("TPA_IPD_ITEM_TPA_CODE", "Select")
                    @Html.ValidationMessageFor(model => model.TPA_IPD_ITEM_TPA_CODE, "", new { @class = "text-danger" })
                </div>
            </div>
Posted
Updated 3-Nov-17 4:35am
v2
Comments
Karthik_Mahalingam 3-Nov-17 12:54pm    
if it has large number of records replace dropdown list with autocomplete textbox

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900