草庐IT

DropDownList2

全部标签

c# - 如何将枚举类型绑定(bind)到 DropDownList?

如果我有以下枚举publicenumEmployeeType{Manager=1,TeamLeader,Senior,Junior}我有DropDownList,我想将此EmployeeType枚举绑定(bind)到DropDownList,有什么办法可以做到这一点吗? 最佳答案 如果你有一个名为ddl的DropDownList对象,你可以像下面那样做ddl.DataSource=Enum.GetNames(typeof(EmployeeType));ddl.DataBind();如果您希望枚举值返回选择....EmployeeTy

c# - 如何在 MVC 的 Controller 中获取 DropDownList SelectedValue

我有下拉列表,我从数据库中填充了它。现在我需要在Controller中获取选定的值进行一些操作。但没有得到这个想法。我试过的代码。型号publicclassMobileViewModel{publicListMobileList;publicSelectListVendor{get;set;}}ControllerpublicActionResultShowAllMobileDetails(){MobileViewModelMV=newMobileViewModel();MV.MobileList=db.Usp_InsertUpdateDelete(null,"","",null,""

c# - 从数据库填充 DropDownList 的正确方法是什么?

我正在从SQLServer数据库填充DropDownList,如下所示。它工作正常,但我不确定这是一个好方法。有人可以阐明这种方法并进行一些改进吗?privatevoidLoadSubjects(){ddlSubjects.Items.Clear();stringselectSQL="SELECTSubjectID,SubjectNameFROMStudents.dbo.Subjects";SqlConnectioncon=newSqlConnection(connectionString);SqlCommandcmd=newSqlCommand(selectSQL,con);SqlD

c# - 带有 Razor 的 MVC 4 中的 DropDownList

我正在尝试在RazorView上创建一个DropDownList。有人会帮我吗?普通HTML5代码:Exemplo1Exemplo2Exemplo3我试过这个:@{varlistItems=newList{newListItem{Text="Exemplo1",Value="Exemplo1"},newListItem{Text="Exemplo2",Value="Exemplo2"},newListItem{Text="Exemplo3",Value="Exemplo3"}};}@Html.DropDownListFor(model=>model.tipo,newSelectList

关于 ASP.NET 和 JQuery:ASP.NET 和 JQuery – Popup for dropdownlist selected value

ASP.NETandJQuery-Popupfordropdownlistselectedvalue如果在我提交表单之前新选择的下拉列表的值是某个值,我要做的是弹出一个"你确定"确认框。12345  Closed  Open  Pending因此,如果我在启用自动回发的情况下启用了上述下拉列表,如果用户在提交表单之前选择"关闭",我想弹出一个确认框。12345678$("#ListSearchType").onchange(function(){  if($(this).val()=="C"){    varconfirmed=confirm("Areyousure?");    if(!co

关于 ASP.NET 和 JQuery:ASP.NET 和 JQuery – Popup for dropdownlist selected value

ASP.NETandJQuery-Popupfordropdownlistselectedvalue如果在我提交表单之前新选择的下拉列表的值是某个值,我要做的是弹出一个"你确定"确认框。12345  Closed  Open  Pending因此,如果我在启用自动回发的情况下启用了上述下拉列表,如果用户在提交表单之前选择"关闭",我想弹出一个确认框。12345678$("#ListSearchType").onchange(function(){  if($(this).val()=="C"){    varconfirmed=confirm("Areyousure?");    if(!co

关于 c#:Inserting DropDownList item into SQL Database

InsertingDropDownListitemintoSQLDatabase我有一个DropDownList,其中填充了来自SQL表的数据。在网络表单中,当用户从该列表中选择一个项目时,我希望它将所选的选项插入另一个SQL表中,除了DropDownLists之外的所有内容都有效我试过了:12cmd.Parameters.AddWithValue("@*",ddl*.SelectedValue);cmd.Parameters.AddWithValue("@*",ddl*.SelectedItem.Text);等12345678910111213141516171819202122232425

关于 c#:Inserting DropDownList item into SQL Database

InsertingDropDownListitemintoSQLDatabase我有一个DropDownList,其中填充了来自SQL表的数据。在网络表单中,当用户从该列表中选择一个项目时,我希望它将所选的选项插入另一个SQL表中,除了DropDownLists之外的所有内容都有效我试过了:12cmd.Parameters.AddWithValue("@*",ddl*.SelectedValue);cmd.Parameters.AddWithValue("@*",ddl*.SelectedItem.Text);等12345678910111213141516171819202122232425