下拉值获得一些不必要的数据 [英] Dropdown value get some unnecessary data

查看:74
本文介绍了下拉值获得一些不必要的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个依赖的下拉菜单。



类别和名称



指定取决于类别。在类别指定数据的chagne得到。



但是当我直接点击时间指定时..默认初始值设置(指定ID)。每个选项都包含一个单词。

opetion1:d,

option2:e,

option3:s,

选项4:我

选项5:g,



等等..

 < option> d< option> 



< option> e< option> 



< option> s< option> 



< option> i< option> 





< pre>< option> ..指定..< option> 





我的尝试:



< div class =input-field col s6> 

@ Html.DropDownList(DesignationId,new SelectList(DesignationId,DesignationName),Select Job Post,new {@class =validate select-active})
< label for =Departmentclass => Department< / label>
< / div>

解决方案

Quote:

新的SelectList(DesignationId,DesignationName)



查看文档 [ ^ ],第一个参数 SelectList 构造函数是一个 IEnumerable 序列,包含要显示的值。



您传入的是 String ,这是一个可枚举的字符序列。因此,您的列表将包含字符串中每个字符的一个条目。



相反,您需要传入一个可枚举的指定序列作为第一个参数。


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">
 
 @Html.DropDownList("DesignationId", new SelectList("DesignationId", "DesignationName"), "Select Job Post", new { @class = "validate select-active" })
<label for="Department" class="">Department</label>
 </div>

解决方案

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.


这篇关于下拉值获得一些不必要的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆