0
How to pick up the selected value on dropdownlist
?
I need to take the selected value and pass this value to a session
.
I did with textbox
this way and it worked, but with dropdownlist
doesn’t take the value.
I did the following:
View
@Html.DisplayNameFor(model => model.IRPJ) :
@Html.DropDownListFor(model => model.IRPJ, new SelectList(new List<Object>
{
new { value = 0, text = "1,5"},
new { value = 1, text = "4,8"}
}, "value", "text", 0))
Controller
[HttpPost]
public ActionResult Detalhes(FormCollection frm)
{
object irpj = frm[1].ToString().Replace(".",",");
Session["IRPJ"] = irpj;
return RedirectToAction("ImprimirBoleto", new
{
irpj = Session["IRPJ"].ToString(),
});
in this form, you only send this field?
– Rafael Cabral
@Rafaelcabral, No, send others, put only this pq was the only one I need that I didn’t know, the others are textbox and that way it worked.
– AndreeH
then the @Rafaelmathias solution solves
– Rafael Cabral