FAQ Database Discussion Community


problems on dynamic dropdown lists

php,dynamic,html.dropdownlistfor
I am currently working on a a drop down list which fetch all college names in my college table I was wondering how can I make a another drop down list in which it fetches all departments in the currently selected collage name without using a form (for the page...

ASP.MVC 5 Dropdown on Create page

asp.net,asp.net-mvc,asp.net-mvc-5,html.dropdownlistfor
I have 2 models, and i need to show Groups dropdown on Students create page. Now i have page, where i can choose group, but i don't see choosed variant after submit (student.Group is null in [POST]Index). What's can be the problem? public class Student { [Key] [ScaffoldColumn(false)] public string...

Populate DropDownListFor and default value is guid parameter

drop-down-menu,asp.net-mvc-5,guid,html.dropdownlistfor
I have populated a DropDownListFor with all the correct values. I'm passing a Guid parameter, but don't know how to set the default value to that Guid. View <div class="form-group"> @Html.LabelFor(model => model.Parent) @Html.DropDownListFor(model => model.Parent, new SelectList(Model.AllParents, "Id", "Name"), string.Empty, new { @class = "form-control" }) @Html.ValidationMessageFor(model => model.Parent)...

DropDownListFor selected value not working

html,asp.net-mvc,razor,html-helper,html.dropdownlistfor
So I have this in my view(I have broken it out into a foreach so I could debug it properly). And according to the objects that are created it looks good. I get 1 item that has the selected true. @{ var useritems = new List<SelectListItem>(); foreach (var si in...

How to update multiple dropdownlists using Ajax in Asp.net-MVC

jquery,ajax,asp.net-mvc,html-helper,html.dropdownlistfor
I have multiple identical dropdownlists created by a @html helper. In each dropdown, there is one option which is named "Create a new one". When I click this option, there is popup showing up and allows me to fill out infor and create a new option. I'm totally up to...

how to get dropdown lists text jquery

jquery,html.dropdownlistfor
var colDdl = $('#ColumnSelection').text(); var filterDdl = $('#FilterOptions').text(); Above is my code where I am trying to get the text of the selected dropdown list item. If i use the .val(), I get the value(1,2,3 etc). How do I get the text. Above code gives me null in the respective...

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

java,sql-server,jstl,html.dropdownlistfor,linkedhashmap
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...

assign a dropdownListfor to an “All” option with value=0

asp.net-mvc,html.dropdownlistfor
i have a dropdownList for in my view to which i want to assign an All option with value 0 Suppose <option value="0">All</option> <option value="1">Account A</option> <option value="2">Account B</option> And so on , if user dont select any one option by default its selected value should be 0 All.. what...

List to DropDown list in Yii

php,yii,html.dropdownlistfor,yii-chtml
Please help with this code: <ul class="activity-projects"> <?php foreach ($ownProjects as $userProject) : ?> <li> <a class="<?php echo ($userProject->id == $project_id) ? 'active' : '';?>" href="<?php echo Yii::app()->createUrl('user/activity', array( 'user_id'=>$user->id, 'project_id'=>$userProject->id, 'date'=>$date) ); ?>"><?php echo $userProject->name; ?></a> </li> <?php endforeach; ?> <?php foreach ($projects as $userProject) : ?> <li> <a...

yii2 inserting 2 params as text inside dropdownlist

activerecord,drop-down-menu,yii2,html.dropdownlistfor
Here is yii2 drop down list. <?php echo $form->field($model, 'param1')->dropDownList( ArrayHelper::map(Model::find()->all(),'param1','param2'); It makes drop Down list with values of param1s and text to choose from of param2s. So you see param2 texts , choose one and corresponding param1 value goes to server. No my problem is that I want to...

MVC DropDownListFor - SelectedItem not working for nested value

c#,asp.net-mvc,asp.net-mvc-4,enums,html.dropdownlistfor
In my C#, MVC4 .NET WebApplication I have a custom helper that has the following method-call: @Custom.DropDownListFor(m => m.CategorySetups[categoryId].Gender, CategoryHelper.Genders, new { @class = "form-control" }) which is internally something like: @Html.DropDownListFor(expression, new SelectList(items, "Value", "Text")) because I have an override of SelectListItem here. This call is not selecting the...

MVC5 Scaffolding Dropdowns Out the Box

asp.net-mvc,asp.net-mvc-5,poco,html.dropdownlistfor,asp.net-mvc-scaffolding
I want to view, edit and create with drop-down list of my lookup relationships. Sometimes this works, sometimes it doesn't. It's a mystery that I'm hoping can be definitely solved here. Here's my POCO's for the lookup public class Color { public int Id { get; set; } public string...

Use viewmodel to bind data with html.dropdownlistFor in asp.net-MVC

c#,asp.net-mvc,repository-pattern,html.dropdownlistfor,model-view
I need to create @html.dropdownlistFor where data is coming from database. I have modelView which combining two classes. One for user and another one is Group. it suppose to show records of user in grid table along with drop down where group can be selected for that particular user. View...

Disable & Specify default selection for Html.DropDownList

asp.net-mvc,razor,asp.net-mvc-5,html.dropdownlistfor
i am working on an asp.net mvc web application, inside the action method i define the following select list:- ViewBag.ApproverID = new SelectList(db.staffs.ToList(), "ApproverID", "Name"); Then on the view i am trying to disable the dropdownlist as follow:- @Html.DropDownList("ApproverID",String.Empty,new { @disabled = "disabled" } ) but seems the dropdownlist does...

How to Pass Kendo DropDownList DataTextField value to Controller

asp.net-mvc,kendo-ui,kendo-asp.net-mvc,html.dropdownlistfor,kendo-dropdown
I have a Kendo DropDownList on the View and I want to pass its DataTextField value to the Controller and then pass and them on the labels in another View. Although I can pass DataValueField values to the Controller, I cannot pass DataTextField values. I tried to apply different scenarios...

Post part of a form Asp.net mvc

jquery,asp.net-mvc,textbox,html.dropdownlistfor
I have a form including two textboxes, two dropdownlists and one label. When I fill the first two textboxes and select values of the two dropdownlists, all the values will be concatenated and put into the label one. So now when I click button Save, I want to post only...

How create Dropdown list only using ViewBag in ASP.NET MVC 4?

asp.net-mvc-4,html-select,html.dropdownlistfor,viewbag
Here I have a model class.. public class MyDrop { public int id { get; set; } public string value { get; set; } } In my controller I use this code.... public ActionResult Index(){ var GenreLst = new List<MyDrop>(); MyDrop a = new MyDrop(); a.id = 1; a.value =...

MVC - Changing default text in dropdown

asp.net-mvc,razor,enums,html.dropdownlistfor
I have a view model that contains an enum: public class PasswordChangerIndexViewModel { public enum DatabaseTypes { Main = 10, Florida = 20, Illinois = 30, Missouri = 40, NewHampshire = 50, NewJersey = 60, Oklahome = 70 }; [DisplayName("Database")] public DatabaseTypes DatabaseType { get; set; } } And in...

In asp.net-mvc, How can I insert a class name from my view model for a html.dropdownlistfor

c#,asp.net,asp.net-mvc,viewmodel,html.dropdownlistfor
I have the following code in my view: <%= Html.DropDownListFor(r=>r.Id, Model.MyList, new { @class = "Dropdown hidden" })%> but now I want to only assign the class "hidden" in certain cases so I want to pass that in from my ViewModel to either add the class or to leave it...

Assign selectlist to dynamically created dropdown in MVC

asp.net-mvc,html.dropdownlistfor
I have static select list as below var listItems = new SelectListItem[] { new SelectListItem(){Text="-- Please Select --",Value=""}, new SelectListItem(){Text="Death",Value="Death"}, new SelectListItem(){Text="Resignation",Value="Resignation"}, new SelectListItem(){Text="Retirement",Value="Retirement"}, new SelectListItem(){Text="Termination",Value="Termination"}, new SelectListItem(){Text="Transfer",Value="Transfer"}, }; ViewBag.DeletionReason = listItems; and assigning the same to ViewBag. Now in my page i have to search for a staff ID....

How to move to another view from dropdown list in ASP.NET mvc

c#,asp.net-mvc,html.dropdownlistfor
I'm stuck here for over a week. I'm trying to create a dropdown list where when a user clicks on certain value from the dropdown list, it will redirect to another view called index. So below is my dropdown code. Values in the dropdown list is obtained from SQL Server....

Trouble setting selected value of strongly typed MVC SelectList

asp.net,asp.net-mvc,razor,html.dropdownlistfor,selectlist
Get the data from the database and tack on the option I plan to be the default selected: public List<Forester> GetForesters() { var data = _db.tblForester.ToList(); List<Forester> ForesterList = new List<Forester>(); foreach (var item in data) { Person person = new Person() { Key_ = item.Key_, FirstName = item.FirstName, LastName...