I have three drop downs in mypage.php:
<select name='vehicle'>
<option value=''>Select</option>
<option value='bus'>Bus</option>
<option value='bike'>Bike</option>
<option value='car'>Car</option>
</select>
<select name='color'>
<option value=''>Select</option>
<option value='red'>Red</option>
<option value='blue'>Blue</o...
As far as I can tell, there are 3 ways to create a DropDownList in an ASP.NET MVC View:
Hand code the HTML manually
<asp:DropDownList ID="someID" runat="server"></asp:DropDownList>
<%= Html.DropDownList("someID") %>
I think we can all agree that #1 is (generally) a waste of time.
With #2, it appears to be the "WebForms" way of doing...
In my ASP.NET application, I have a GridView. For a particular field in this GridView, I've added an EditItemTemplate with a DropDownList. However, if the value of the field is "X", then I want to just display a label instead of the DropDownList. So how can I programatically check the field value, then decide which control to display?
H...
hi,
i am getting error after post, when i am using dropdown in my mvc website, the code is as follows
ViewData["JobSite_JobCategories1"] = new SelectList(context.JobSite_JobCategories, "Id", "Category", null);
<%= Html.DropDownList("JobCategory", ((IEnumerable<SelectListItem>)ViewData["JobSite_JobCategories1"]))%>
<%= Html.ValidationM...
I have something basic generated from nifty_scaffold in a partial form: _form.html.erb
<p>
<%= f.label :group_id %><br />
<%= f.text_field :group_id %>
</p>
Instead of a text field I want to convert the above from text_field to a drop down list which will be populated with groups which I set below.
My new action in Emplo...
I know there are many similar questions already, but I've spent hours trying to figure this out and none of the other answers seem to help!
I want to just display a list of strings in a drop-down list using MVC. Is this really so difficult? I don't have a "Text" and "Value" separation (athough MVC appears to require one) - the string di...
Hello, I have a nav bar with a drop down that is working beautifully. The only thing I am trying to change, is when you hover over the main links, the sub-links/text are on top of eachother. I want them to display horizontally. I have tried all sorts of floats and display inline etc...
Here is a portion of the HTML:
<ul id="top_main_na...
Hey guys,
Probably a simple one, but I need some help. I had some radio buttons and was using the following jQuery to see which was checked:
var desc1 = ($('input[name=area]:checked').val());
That worked fine, but I now need to use a drop down menu instead of the radio buttons. I tried the same jQuery and also with "selected" instead...
In my admin section, when I edit items, I have to attach each item to a parent item. I have a list of over 24,000 parent items, which are listed alphabetically in a drop down list (a list of music artists).
The edit page that lists all these items in a drop down menu is 2MB, and it lags like crazy for people with old machines, especiall...
I'm trying to set up a form with multiple dropdown lists, that will allow visitors to rank the list items. Sample form:
<form action="" name="rankem">
<select name="rank1" id="rank1">
<option value="option1">Option 1</option>
<option value="option2">Option 2</option>
<option value="option3">Option 3</option>
<option v...
I want to show a confirmation dialog when a specific value is selected in an asp:DropDownList. If the confirmation dialog returns false (cancel) then I want to prevent the AutoPostBack.
<asp:DropDownList id="theDropDownID" onchange="foo()"></asp:DropDownList>
However, it ignores the returned value from foo() and actually does the post...
I don't recall ever running into this problem, but I have a gridview inside an UpdatePanel. The gridview has a DropDownList in a templated column. The DropDownList is populated during a RowDataBound event by binding to a generic list of strings.
On the ASPX side, I have the templated row setup with a AutoPostBack="True" and a OnSelect...
I seem to lose the postback, even if i have AutoPostback="true" and OnSelectedIndexChanged="grid_SelectedIndexChanged". Anyone ever get this to work?
-Romel Evans
...
Hello!
I use DetailsView to insert rows in database. Row has fields id, subcategory_id etc. I want to fill dynamically dropdownlist ddl_subcategories, which is used in TemplateField. Selected item value of first dropdownlist ddl_categories is used as parameter for generating collection for ddl_subcategories. I try it with using UpdatePan...
I have a DropDownlist that prompts a user for the State, when the user selects a state, ie. Colorado, it saves 'CO' in the database, works great. When the user goes back to the page, it shows 'CO' in the dropdown, but when the page posts back, the dropdownlist value is null. If I manually select a State again, posts back with the corre...
I have the following database schema:
Here's how I populate a DropDownList in my AreaController.cs:
public ActionResult Edit(int id)
{
Area area = areaRepository.GetArea(id);
JefeRepository jefe = new JefeRepository();
ViewData["Jefes"] = new SelectList(jefe.FindAllJefes().ToList(), "ID", "Nombre", area.Jefe.Nombre);
r...
Hey,
I'm putting together a fairly simple HTML/Javascript/PHP form (I am fairly new to all of these). One field of the form requires users to select an option from a reasonably long list (using a drop down list). The contents of the list are extremely unlikely to ever change. Is there a "better" way to populate the list than simply usi...
i have to make dropdownlist updateable
the data come form database and show in dropdownlist
for user form
like make country
indai
uk
australi
and the user can update it how can i do it using c#
thank's
...
Hello!
I use DetailsView with ObjectDataSource to insert entry in database. DropDownList ddl_kinds is bound to some field. I complete dropdownlist dynamically. Last listItem of dropdownlist has TextField "Null value" and ValueField "0". But when I choose this item in DetailsView and try to send form, FormatException is thrown.
There is...
Hello. I have a 1024px nav bar that has five categories that are links (ul's) A few of them have drop downs. I have them set up perfectly to align horizontally. The one to the far left when hovered, drops down the text perfectly to left edge underneath the nav bar, as intended. As you move down to the right, the text(the hovered text) on...