如何绑定DROPDOWN列表从MVC 5中的数据库 [英] how to bind DROPDOWN list From database in MVC 5
问题描述
大家好,
这里我是MVC新手。所以如何设置TEXTBOX \DROPDOWN并从table.can绑定你简要解释我。并添加水印。
DESCRIPRION:
如果我想输入一个起始字母并且它将成为文件管理器。还有一个想法在下拉列表中显示5个成员然后我们将滚动下一个确定。不显示下拉列表中的所有成员它只会限制我们将滚动另一个确定。
hi to all,
Here i'm new for MVC. so how to set TEXTBOX\DROPDOWN and it bind from table.can you explain me briefly.and add Water mark.
DESCRIPRION:
If i want to type a starting letters and it will filer .And one more think in dropdown oly show 5 members then we will scroll for next one ok. dont show all the members in dropdown it will limited only then we will scroll for another one ok.
推荐答案
@Html.TextBox("txtNane", "Enter Your WaterMark", new
{
id = "txtId",
onfocus = "if(document.getElementById('txtId').value=='Enter Your WaterMark')document.getElementById('txtId').value='';",
onblur = "if(document.getElementById('txtId').value=='')document.getElementById('txtId').value='Enter Your WaterMark';"
})
如果您想要更多声明onfocus上的函数名称或textbox lik的onblur方法设置forcolor灰色等..你可以制作javascript函数并调用它。
用于绑定
if you want more statement in a function name on onfocus or onblur method of textbox like set forcolor gray etc.. you can make javascript function and call it.
for binding
@Html.TextBox('',Your Bind Object)(in above i have bind string 'Enter Your WaterMark'
dropdown for show only 5 record you have to take a dropdown under div tag and set height of div with autoscroll style
Bind Drop Down List with Datasource in my case i have List<string>
<pre> @Html.DropDownListFor(s => s.myFriendList, new SelectList(Model.myFriendList))
这篇关于如何绑定DROPDOWN列表从MVC 5中的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!