Click here to Skip to main content
15,891,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have one dependent dropdown.

category and designation

designation is dependent on category. on chagne of category designation data get.

but when i direct click on designation that time .. default initial value set (designationid). every option contain one word.
opetion1 : d ,
option2 : e ,
option3: s ,
option4 : i
option5 : g ,

and so on..
<option>d<option>

<option>e<option>

<option>s<option>

<option>i<option>


<pre><option>..designation ..<option>


What I have tried:

<div class="input-field col s6">
 class="mdi-action-account-balance prefix">
 @Html.DropDownList("DesignationId", new SelectList("DesignationId", "DesignationName"), "Select Job Post", new { @class = "validate select-active" })
<label for="Department" class="">Department</label>
 </div>
Posted
Updated 20-Nov-17 4:56am
v2
Comments
Karthik_Mahalingam 20-Nov-17 7:00am    
not clear, Use Improve question to add more info to the question.

1 solution

Quote:
new SelectList("DesignationId", "DesignationName")

Looking at the documentation[^], the first argument to the SelectList constructor is an IEnumerable sequence containing the values to display.

You are passing in a String, which is an enumerable sequence of characters. Therefore, your list will contain one entry for each character in the string.

Instead, you need to pass in an enumerable sequence of designations as the first parameter.
 
Share this answer
 
Comments
Jaydeep Shah 20-Nov-17 21:35pm    
so what exactly i have to change here. add first argument

@Html.DropDownList("DesignationId",new SelectList(listItems,"DesignationId","DesignationName")) !! is it ??
Richard Deeming 21-Nov-17 8:54am    
Yes, that should do it.
Karthik_Mahalingam 21-Nov-17 3:21am    
5 good catch

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900