selectlist

Get ALL items in a SelectList within ASP.NET MVC controller

Is there a way to post all items in a SelectList (multiselect) to the method of a controller? By default when I use a SelectList it will only post the selected items to the Form. I have a couple of MultiSelect controls on a View. Using jQuery the user can move items from ListBox1 to ListBox2 and vice versa. When the form is posted I wan...

Insert value into selectlist

I need to insert a value into a selectlist. It isn't the "0" value (i.e. the first one that shows) but the next one which would be "Other". This is then used to display an "Other" textbox. My question is similiar to link text. EDIT: I don't know if this will help but here is the code: SelectList Titles; ViewData["Titl...

How to get the value of datafieldtext or selectedtext of the selectlist in asp.net mvc?

No javascript\AJAX is to be used. ...

.net MVC, SelectLists, and LINQ

I am new to using the Html.DropDownList in the MVC framework and am having a hard time understading how to select the data out my database to bind to the DropDownList. Is there an easy way to return a bindable list (such as a SelectList) from a standard LINQ query? ...

MVC / EF Query -- A better way?

Objective: Get a list of name|id pairs for a select list from table A where the id does not exist in a filtered collection of Table B records. Constraints: Using MVC 1.0, Entity Framework (no L2S, DataContext, etc.), C# My question is whether there's a smarter way to go about doing this than what I've got working so far--which just s...

Formatting SelectList Items

Hi all, I was wondering if there was a way to format 2 strings in a selectlist and display them as following: String begins with Item1 and spaces following it until 10 spaces are taken up followed by a Delimiter "|" and string 2 So all Selectlist items binded to a drop down list will be displayed as following Item 1 |Name1 Item 2...

MVC & SelectList

Is there a way to output select list to a string in the View ? //Javascript var comboHtml = <%= Html.Encode(Model.MySelectList.ToHtml()) %> or would i have to enumerate the list my self to create the html, need this for a dynamic form field. ...

Simplest method to create an asp.net mvc dropdownlist with values from 0 to 10?

Hi, I'm new to asp.net mvc, so excuse me if my question is too simple. I just want a dropdownlist that goes from 0 to 10 using Html.DropDownList. What is the fastest way? At the moment i only see the solution creating a IEnumerable of SelectListItem, add 10 values and pass it through with the viewdata, but i think that's overkill, how t...

HTML: Radio buttons connected to select lists

Excuse my lack of html knowledge, but is it possible to set up a set of say 3 radio buttons so that each one links to a different select list of items? What I'm trying to do is let the user select either: Projects select list of all the projects, Tasks select list of all the tasks, Users select list of all the users As far as I have b...

LINQ Union with Constant Values

Hi; Very primitive question but I am stuck (I guess being newbie). I have a function which is supposed to send me the list of companies : ALSO, I want the caller to be able to specify a top element for the drop-down list as well.. (say for "None"). I have following piece of code, how I will append the Top Element with the returning Sele...

What is wrong with my ASP.NET MVC SelectList?

I'm trying to use a SelectList one of my views, and its just not populating correctly. It gets the proper number of entries (4), but they all read System.Web.Mvc.SelectListItem. I fired up the debugger on the code, and saw some strangeness going on. I must be doing something wrong, but I don't quite see what. Code from the ViewMode...

ASP.net MVC: Creating SelectList in the view or action?

Hey guys I'm just wondering where people are creating their SelectList - in the action or the view. I have seen examples of both and the one that makes the most sense to me is doing it in the action and have the view model have a property of type SelectList. On the other hand, I have seen examples where people have the view model h...

Populating Selectlist from multiple fields

My problem is pretty simple. Lets say I have a dropdown with users. in the database i have 3 fields for my user table: user_id user_name user_firstname in my MVC app i want to link those users to projects. so thats why i want the dropdown. now, i want to have a selectlist, with the ID as the value, and the firstname AND lastname t...

ASP.NET MVC Model vs ViewData For Select Lists

I have an ASP.NET MVC application with quite a few drop-down lists and multi-select lists. Essentially, a lot of lists of options. My question is; is it better to pass these lists to the view as part of the Model, or as ViewData? I am currently passing them as ViewData as I don't really need them on the model and they seem potentially ...

Alternative to onChange or onBlur in jQuery dropdownchecklist control

Currently using the jquery dropdownchecklist found here: http://dropdown-check-list.googlecode.com/svn/trunk/src/demo.html I'm doing some pretty heavy processing of a large quantity of data on the client with a number of dropdownlists. Essentially, and put very simply, as each dropdown changes the data in each is filtered. I'm using the...

Strongly typed view with a SelectList for DropDownList via ViewData: type mismatch on submit

I am trying to create a form in ASP.NET MVC2 RC 2 that is based on a calendar event object. The object has eventTypeId which is a System.Int32 that I need to populate with via a select list. The controller to create the initial view is: [WAuthorize] public ActionResult AddCalendarEvent() { CalendarEventTypesManager calendarEventTyp...

ASP.NET MVC SelectList: How do I set class name and other attributes?

How can I set a select class and other attributes eg:events through the SelectList object? If this cannot be done, what are the best practices in populating a select input (dropdownlist) ie should I just loop through the items and render the <option> tags I guess events should be bound to the controls in jquery for instance, but I do n...

Model binding form to a List using dropdown. binding failing 1 way for dropdown

I have an action called Sessies. In this action i am creating 'Sessies' objects from a form. if they don't exist i add them in the DB, if there are already Sessies objects connected to the 'Reeksen' object, i load the 'Sessies' into the form so that they can be edited. so i have a create and edit in 1 and the same form. Also, a 'Reeksen...

How to code a C# Extension method to turn a Domain Model object into an Interface object?

When you have a domain object that needs to display as an interface control, like a drop down list, ifwdev suggested creating an extension method to add a .ToSelectList(). The originating object is a List of objects that have properties identical to the .Text and .Value properties of the drop down list. Basically, it's a List of Select...

WatiN SelectList Methods - Page not refreshing/actions not being fired after interacting with a select list

Preface: If you don't care about the preface, skip down to the section marked "Question." Hi, Recently my company has upgraded to the latest version of WatiN for its test automation framework. We upgraded to avoid a problem where interacting with a select list would cause an ACCSES DENIED error. This error seems to be a product of t...