C# 如何基于ID删除下拉列表中的项目
我的视图中有一个下拉框,我想根据客户ID进行更改。我不知道从哪里开始,我考虑过使用Javascript,但我宁愿避免使用它,因为有些用户可能会关闭Javascript 视图模型:C# 如何基于ID删除下拉列表中的项目,c#,asp.net,C#,Asp.net,我的视图中有一个下拉框,我想根据客户ID进行更改。我不知道从哪里开始,我考虑过使用Javascript,但我宁愿避免使用它,因为有些用户可能会关闭Javascript 视图模型: public class ReportType { public int ReportID { get; set; } public string ReportName { get; set; } } public IEnumerable<ReportTyp
public class ReportType {
public int ReportID { get; set; }
public string ReportName { get; set; }
}
public IEnumerable<ReportType> ReportTypeOptions = new List<ReportType>
{
new ReportType {ReportID = 0, ReportName = "Claims by Supplier"},
new ReportType {ReportID = 1, ReportName = "Department Breakdown"},
new ReportType {ReportID = 2, ReportName = "Reason Code Breakdown"},
new ReportType {ReportID = 3, ReportName = "Monthly Debiting Report"},
};
“一些用户可能已经关闭了Javascript”,这是不太可能的scenario@naveen是的,但这不是重点。你能详细说明这个问题吗?什么id,什么类型的过滤。。。诸如此类that@naveen我有一个客户ID,我需要查看我的视图。并且取决于客户ID。我需要能够删除或禁用每月借记Report@AndrewKilburn您可以在控制器上选择所有ur条件,然后通过查看包传递列表,并使用该列表绑定下拉列表
@Html.DropDownListFor(m => m.ReportTypeOptions.First().ReportID, new SelectList(Model.ReportTypeOptions, "ReportID", "ReportName"), "Select Report", new { @class = "GRDropDown", @id = "ReportDD", onchange = "disableFunction()" })