c# - How to Prevent Drop down to show values that is in Database -
i want prevent value of dropdown list when in database file theres no multiple input in database ,
i hope can me problem ,
i'm using mvc 3 , kendo ui
is possible handle via jquery or linq statement in controller ?
thanks :)
<span> @html.dropdownlist("ddlday", new selectlist(viewbag.daylist, "id", "display_value", personday), "[please select]", new dictionary<string, object> { {"class","validate[required] inputlong"} }) </span>
this dropdown show monday sunday , have 2 of drop down shows availability know if save monday wednesday , monday wednesday removed on 2 dropdowns ,
private void getdaylist() { var daylist = (from in db.lookups a.domain == "daystatus" select a).tolist(); viewbag.daylist = daylist ; }
you can solve in many ways, depend on how interaction done.
you use linq, adding where() or except() statement filter full list:
var fromdaylist = daylist.where(day => day.name != selectedfromday).tolist(); // or if multiple selected days, assuming of same type: var validdaylist = daylist.except(selecteddaylist).tolist();
if allow them change selected days client side , using ajax (which how use kendo ui) won't want filter server side. instead should wrap daylist
in kendo.datasource
, apply filter based on selected days in javascript. haven't provided enough information me supply sample code this.
Comments
Post a Comment