html.dropdownlistfor

Build an empty MVC DropdownListFor for a Cascade Sub-List

点点圈 提交于 2019-12-03 04:07:00
问题 I would like to build an empty Dropdownlistfor to received the results of a previous Dropdownlisfor selection: The actual view: <div id="makes"> @Html.DropDownListFor(m => m.Make_Id, Model.MakeList, HeelpResources.DropdownlistMakeFirstRecord) </div> <div id="models"> @Html.DropDownListFor(m => m.Model_Id, Model.ModelList, HeelpResources.DropdownlistModelFirstRecord) </div> The actual Controller (to work I had to build an empty SelectedList but it seems strange to have to do this): public

In Yii framework how can I Combine columns and show as display string in dropdownlist

隐身守侯 提交于 2019-12-03 03:06:01
I have a dropDownList in my view, it is populating from clients table, the table contains columns like first_name , last_name , id etc., Now I want to show the first_name and last_name as display text and id as value in drop down list, I'm done with id as value and first_name as display text, but here I want to combine those columns ( first_name and last_name ) and use as display text. in model function getClients() { $Clients = Client::model()->findAll(); $list = CHtml::listData($Clients , 'client_id', 'first_name'); return $list; } in view echo $form->dropDownList($model,'client_id',$model-

MVC DropDownList OnChange to update other form fields

限于喜欢 提交于 2019-12-02 20:47:50
I am new to MVC (I am moving over from the dark side of traditional ASP.Net) and I know that SO is more of a "why doesn't this work" but, being new to MVC, I just wanted to ask how something is achieved - I don't really have any code or markup because I don't know how at the moment. Right, using an analogous example... I have a form that has a drop-down of a list of "Widgets" (have that working, thanks to SO) ... and then there are other fields (Length/Height/Width) which have "default" values. When the form displays, the Drop-Down is shown but the form fields of L/H/W are empty/disabled until

DropDownListFor with a custom attribute with - in attribute name?

☆樱花仙子☆ 提交于 2019-12-02 20:11:53
Question: I need to create a dropdownlist like this: <select id="ddCustomers" data-placeholder="Choose a customer" class="chzn-select" style="width:350px;" tabindex="1" multiple> Now I can add custom attributes like this: @Html.DropDownListFor(m => m.Id, Model.Values, new { @disabled = "disabled" }) Unfortunately, if there is a "-" in the variable name, then it doesn't compile. @Html.DropDownListFor(m => m.Id, Model.Values, new { @disabled = "disabled", @data-placeholder = "whatever" }) And what about the multiple, which has no attribute value ? If I pass a Dictionary or a NameValueColletion

Disable enable dropdownlistfor based on model property in mvc

南楼画角 提交于 2019-12-02 18:35:02
问题 I am trying to disable or enable a dropdownlistfor in my mvc application based on model property:- what I am doing is :- @Html.DropDownListFor(m => m.ParentOrganisationID, new SelectList(Model.ParentOrganisations, "ID", "Name", Model.ParentOrganisationID), new { @id = "ddlParentOrganisations", @class = "form-control css-select", @disabled = Model.IsReadOnly ? "disabled" : "false", @style = "width:40%; height:10%;" }) but even if model property "model.IsReadOnly" is false, then also it is

Build an empty MVC DropdownListFor for a Cascade Sub-List

牧云@^-^@ 提交于 2019-12-02 17:55:20
I would like to build an empty Dropdownlistfor to received the results of a previous Dropdownlisfor selection: The actual view: <div id="makes"> @Html.DropDownListFor(m => m.Make_Id, Model.MakeList, HeelpResources.DropdownlistMakeFirstRecord) </div> <div id="models"> @Html.DropDownListFor(m => m.Model_Id, Model.ModelList, HeelpResources.DropdownlistModelFirstRecord) </div> The actual Controller (to work I had to build an empty SelectedList but it seems strange to have to do this): public virtual ActionResult Create() { // Build the Dropdownlist for the Makes var makesDto = _makeService

Html.DropDownListFor confusion

廉价感情. 提交于 2019-12-02 15:40:41
问题 Can someone please help me understand how the Html.DropDownListFor works? I have a model which is as follows public class TestModel { public IList<SelectListItem> ProductNames { get; set; } public string Product { get; set; } } The call to DropDownListFor which looks like @Html.DropDownListFor(model => model.ProductNames, Model.ProductNames, "Select a Product", new {@class="selectproductname" }) With this set up I find that the drop down list gets populated correctly however after submitting

How to populate the dropdown list from sql server database using LinkedHashMap in java

萝らか妹 提交于 2019-12-02 13:16:44
问题 In SQL Server database I have a table which has three columns namely Ref_Name,Ref_from and Ref_to.Now I want a dropdown list to hold values row-wise i.e all column values of the row should be in the dropdown list in following way:- Reference-1(2014-10-10 07:17:00.000 to 2014-10-10 08:46:00.000) Reference-2(2014-09-01 10:00:00.000 to 2014-09-01 11:00:00.000) For this I have used LinkedHashMap as:- public LinkedHashMap<String, List<String>> connect() { ArrayList<String> list = new ArrayList

Disable enable dropdownlistfor based on model property in mvc

六眼飞鱼酱① 提交于 2019-12-02 09:12:14
I am trying to disable or enable a dropdownlistfor in my mvc application based on model property:- what I am doing is :- @Html.DropDownListFor(m => m.ParentOrganisationID, new SelectList(Model.ParentOrganisations, "ID", "Name", Model.ParentOrganisationID), new { @id = "ddlParentOrganisations", @class = "form-control css-select", @disabled = Model.IsReadOnly ? "disabled" : "false", @style = "width:40%; height:10%;" }) but even if model property "model.IsReadOnly" is false, then also it is showing the dropdown as disabled. Please suggest how to handle this, without using any javascript Thanks in

Jquery ajax populate dropdown with json response data

夙愿已清 提交于 2019-12-02 07:44:06
I know there are quite a few questions floating on this but I'm still not sure what to do. I have a HTML form called "CuisineForm", after the user selects the type of cuisine, the AJAX sends the form to the server. The AJAX call works fine, and server responds with a JSON responsewhich contains all the serving times of this particular cuisine. These serving times are divided into Breakfast, Lunch and Dinner. These times need to be populated into 3 separate dropdowns in the same form. but I don't really know how to process the JSON results to populate the 3 dropdowns in the form. Here is the