If you have a viewmodel created, you can simply do for each dropdown.
Up vote 0 down vote favorite share g+ share fb share tw.
I have 2 dropdown lists in MVC 3 razor view like this: @Html. DropDownListFor(m => m. UserGroups, Model.UserGroups.
Select(x => new SelectListItem() { Text = x. Name, Value = x. Id }), new { @class="pad5" }) They work fine.
I have 3 changes to make - 1) First one needs a new option to be added at the top of this list. --pick-- 2) And the second one needs to select a specific option upon load. Say I want to pre-select this option on my second list.
My Friends 3) both dropdowns have same data source. This causing both list to have same name on the form. How do I change the name?
I am able to change the id, but the name seems not changing if I add this to the end: new { @id="ViewGroup", @name="ViewGroup"} asp. Net-mvc-3 razor link|improve this question edited Jun 6 '11 at 18:08 asked Jun 6 '11 at 17:52Projapati1,4471824 72% accept rate.
I can do this by jquery after page load. But prefer to do it in the razor view declarations. – Projapati Jun 6 '11 at 18:11.
If you have a viewmodel created, you can simply do for each dropdown: @model Namespace. MyViewModel --pick-- @foreach (var item in Model. MyModel) { if(@item.
Id==100) { @item. Name } else { @item. Name } }.
– Projapati Jun 6 '11 at 18:33 I don't know to be honest, I tried it with DropDownListFor, but the problem is that for my programming, I have a lot of conditionals, so it was a pretty long line, and I found this way personally easier. – user759458 Jun 6 '11 at 18:39.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.