similar example
Problem is my selectlist might have data(plus it's format is something like [Ford IV 200 xyx]) in it which I want to retire(by only displaying records which has a bit value of true in it's 3rd column which is also something I need to figure out how to do), big problem is if the user adds in say another Ford which would now display all the way at the bottom of the drop down it would look very messy and could even be overlooked so any ideas?
p.s. added jquery to the tags in case that was a possible solution to this since I am able to use that in this project.
Edit - For that 3rd column bit value filter here's the solution
You could use the OrderBy
extension method:
<%: Html.DropDownListFor(
x => x.ModelId,
new SelectList(Model.VehicleModels.OrderBy(x => x.Name), "Id", "Name"),
"-- Select a model --"
) %>
thanks to Darin I was able to come up with the slightly modified solution of his which instead lead to me resolving this in the VM like so
List<Reason> reasonList = _db.Reasons.OrderBy(m=>m.Description).ToList();
ReasonList = new SelectList(reasonList, "Id", "Description");
In case where you have an editor template for your dropdownlist, this will sort it based on text.
selectList.OrderBy(x => x.Text)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With