Home How to filter DropDown list by logged in User in MVC
Reply: 0

How to filter DropDown list by logged in User in MVC

user1209
1#
user1209 Published in June 25, 2018, 7:13 pm

How to filter dropdown list, and i need to take name of logged in User.

in controller i have this code:

    var agentBR = (Session["aID"]);
    ViewBag.AgentID = new SelectList(db.tbl_agenti.Where(x => x.aID.Equals("agentBR")), "aID", "agent_ime");

but not work, session id ok, and in the browser i have this error:

DbComparisonExpression requires arguments with comparable types.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: DbComparisonExpression requires arguments with comparable types.

Source Error:

@Html.LabelFor(model => model.AgentID, "AgentID", htmlAttributes: new { @class = "control-label col-md-2" })

@Html.DropDownList("AgentID", null, htmlAttributes: new { @class = "form-control" })

@Html.ValidationMessageFor(model => model.AgentID, "", new { @class = "text-danger" })

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.310175 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO