我在我的视图中有一个dropdownList,我想为其分配一个值为0的All选项
<option value="0">All</option>
<option value="1">Account A</option>
<option value="2">Account B</option>
Run Code Online (Sandbox Code Playgroud)
依此类推,如果用户默认情况下不选择任何一个选项,其选中的值应为0全部..我试过的是不行的.
这是我的代码任何帮助将不胜感激.
public class ReportViewModel
{
public SelectList Account { get; set; }
public string SelectedAccount { get; set; }
public SelectList User { get; set; }
public string SelectedUser { get; set; }
public SelectList Team { get; set; }
public string SelectedTeam { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
视图
@Html.DropDownListFor(m => m.SelectedAccount, (IEnumerable<SelectListItem>)Model.Account, " ALL ", new { @class = "form-control" })
@Html.DropDownListFor(m => m.SelectedTeam, (IEnumerable<SelectListItem>)Model.Team, " ALL ", new …Run Code Online (Sandbox Code Playgroud) 是否可以将javascript变量作为参数传递给@ url.Action(),因为据我所知可能存在服务器和客户端问题,我的要求是我必须根据过滤器和ajax调用下载文件不适用于下载文件.所以我已经对@ url.Action()进行了编码,但无法实现这一点,任何人都可以建议我如何将参数传递给@ url.Action()或任何其他方法.
这是我的代码
<a href="@Url.Action("Export", new { SelectedAccountType="1", FromDate = "2014-02-02", ToDate = "2014-02-02", SelectedAccount = "", SelectedUser = "", SelectedTeam = "" })" class="btn-primary" id="exportbutton2"> Export as CSV</a>
Run Code Online (Sandbox Code Playgroud)
这是我想要分配给@ Url.Action的参数
<script type="text/javascript">
var accountType = $('#SelectedAccountType').val();
var fromDate = $('#FromDate').val();
var toDate = $('#ToDate').val();
var accountId = $('#SelectedAccount').val();
var userId = $('#SelectedUser').val();
var teamId = $('#SelectedTeam').val();
</script>
Run Code Online (Sandbox Code Playgroud) 我收到了这个错误
无法隐式转换
System.Collections.Generic.List<AnonymousType#1>为System.Collections.Generic.List<FirstApp.Model.TeamDetails>
我的代码出了什么问题?
这是我的代码
TeamDetails 类
public class TeamDetails
{
[Key]
public int TeamId { get; set; }
public string TeamName { get; set; }
public string Description { get; set; }
public int? UserCount { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
视图模型
public class ViewTeamList
{
public List<TeamDetails> TeamNext { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
调节器
public ActionResult Next(int dataid)
{
ViewTeamList viewTeamList = new ViewTeamList();
var a = from t in tDbContext.Teams
join u in tDbContext.Users on t.TeamId …Run Code Online (Sandbox Code Playgroud)