Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C++
@Html.DropDownListFor(x =>x.Scheme_id, new SelectList(Entity.MBL_MAST_ASST_SCHEME.ToList(), "Scheme_id", "Scheme_Name"), "select", new { @class = "form-control2new",@id="Schemeid"})


What I have tried:

MBL_MAST_ASST_SCHEME is my table name and i am bind table value from view page and i want to use where clause like where langId=1 in this dropdow so how to use it

please help me
Posted
Updated 4-Apr-18 2:36am
v2

1 solution

When you bind a dropdown list in the Razor view, the source is List<selectlistitem> which can be treated as normal collection type in c#. Below is how you can apply where clause for dropdown in MVC.

@Html.DropDownListFor(x =>x.Scheme_id, new SelectList(Entity.MBL_MAST_ASST_SCHEME.ToList().Where(L=> L.Value=="comparedvalue"), "Scheme_id", "Scheme_Name"), "select", new { @class = "form-control2new",@id="Schemeid"})
 
Share this answer
 

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