Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Passing a Parameter Value from Controller to View to ViewComponent

$
0
0

Hmmm...

I am loading a Create view as:

 public IActionResult QuoteSalesProcedure(int id)
        {
            ViewData["FrequencyID"] = new SelectList(_context.Frequency.OrderBy(i => i.iFrequency), "FrequencyID", "iFrequency");
            ViewData["ProcedureID"] = new SelectList(_context.Procedures.OrderBy(p => p.ProcedureName), "ProcedureID", "ProcedureName");
            ViewData["QuoteID"] = new SelectList(_context.Quote.Include(q => q.QuoteRequest).OrderBy(q => q.QuoteRequest.QDescription),"QuoteID", "QuoteRequest.QDescription", id);


            return View();
        }

This works fine.  It passes in a default value for the quote being worked on.

From the view I want to load a component view, showing procedures already included in the quote.  to do this I need to call the view component something like:

<div>@await Component.InvokeAsync("QuoteProcedures", new {id==id})</div> 

However I don't see how to pass the id value to the view.  I am sure it is simple, and I am overthinking it.  Can I get the Quote ID from the viewbag somehow?  Or do I somehow pass the value as a numeric in the controller to the view?  Or is there a better option?


Viewing all articles
Browse latest Browse all 9386

Trending Articles