第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

將選擇/下拉項(xiàng)的值傳遞給控制器??僅接收 0

將選擇/下拉項(xiàng)的值傳遞給控制器??僅接收 0

C#
慕慕森 2023-12-17 16:51:17
我已經(jīng)成功創(chuàng)建了一個(gè)視圖來(lái)顯示一些投票記錄。但在同一個(gè)視圖上,我嘗試調(diào)用控制器上的另一個(gè)方法來(lái)導(dǎo)出這些記錄,但它只接收 0 作為參數(shù)。這是我的模型。public class Vote    {        public int Id { get; set; }        public int CPF { get; set; }        public virtual Candidate Candidate { get; set; }        public int CandidateID { get; set; }        public DateTime Moment { get; set; }}這是我的索引。public async Task<IActionResult> Index()        {            var context = _context.Vote.Include(v => v.Candidate).Include(v => v.Candidate.Election);            //This is going to be on the view for the user to select the year to export data            ViewData["Election"] = new SelectList(_context.Election, "Id", "Year");            return View(await context.ToListAsync());        }這就是我試圖呼吁的行動(dòng)。[HttpPost]public IActionResult Export(int electionYear)這是我用來(lái)發(fā)布到控制器的表單。@model IEnumerable<Models.Vote>...//Here i show the votes and then below i show this form with the Elections<form asp-action="Export">    <div class="form-group">        <select class="form-control" asp-items="ViewBag.Election"></select>    </div>    <div class="form-group">        <input type="submit" value="Exportar" class="btn btn-default" />    </div></form>我用 [FormBody] 嘗試過(guò),它給了我 415 錯(cuò)誤
查看完整描述

1 回答

?
料青山看我應(yīng)如是

TA貢獻(xiàn)1772條經(jīng)驗(yàn) 獲得超8個(gè)贊

Export 端點(diǎn)需要一個(gè)名為 electionYear 的表單值。但您的 <select> 沒(méi)有 name (或任何 name)。嘗試:

<select name="electionYear" class="form-control" asp-items="ViewBag.Election"></select>


查看完整回答
反對(duì) 回復(fù) 2023-12-17
  • 1 回答
  • 0 關(guān)注
  • 156 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)