Alejandro Hinestrosa
Alejandro Hinestrosa

Reputation: 501

how to get data from my forms

i'm trying to get the data of my forms on my post metod using

public ActionResult  EntradaPedidos(FormCollection formulario) {
         Pedidos miPedido = new Pedidos();
         UpdateModel(miPedido);
         miPedido.division = Request.Form["division"];

what i'm doing wrong? i link my model in the view, and try using different forms.

http://imageshack.us/photo/my-images/13/sinttuloamq.png/

http://imageshack.us/photo/my-images/585/sinttuloecp.png/

this is my view

<% using (Html.BeginForm("EntradaPedidos","home",FormMethod.Post )){ %>

        <% =Html.ValidationSummary("") %>
        <p> 
            <label>Division: </label>
            <%= Html.DropDownList("division", (SelectList)ViewData["divisiones"]) %>
            <!--<%= Html.TextBox("clave1", Model.clave1) %>-->
        </p>   
        <p>
            <label>Número del pedido: </label>
            <label id="numPedido"><% =Html.Encode(Model.numPedido) %></label>
            <!--<% =Html.TextBox ("numeroPedido") %>-->
        </p>
        <p>    
            <label> Fecha: </label>
            <% =Html.TextBox ("FechaInicio") %>

        </p>
        <p>
            <label>Tipo de pedido: </label> 
            <% =Html.RadioButton ("tipoPedido", "1") %><label class="inline" for="TipoPedido">1</label>
        </p>
        <p>
            <label>Transacción de pedido: </label>
            <% =Html.RadioButton("transPedido", "D2") %> <label class="inline" for="TransPedido">D2</label>
        </p>    
        <p>
            <label>Codigo del cliente :</label>
            <% =Html.TextBox ("codigoCliente") %>
            <label id="lbNombreCliente">Nombre del Cliente: </label>

        </p>       
        <p>
            <label>Bodega: </label>
            <% =Html.RadioButton("bodega", "CD") %><label class="inline" for="Bodega">CD</label>
        </p>
        <p>
            <label>Lista de Precios: </label>
            <label id="lbListaPrecios"> </label>
            <%= Html.DropDownList("ddListaPrecios") %>  
           <!-- <%= Html.CheckBox("cbCambioLista") %> <label class="inline" for="cbCambioLista">Desea cambiar lista de precios?</label>  -->
        </p>
        <p>
            <label id="lbCondPago">Condiciones de Pago: </label>            
        </p>
        <p>
            <label>Vendedor: </label>
            <%= Html.DropDownList("ddListaVendedores") %>
        </p>
        <p>    
            <label>Concepto Contable: </label>
            <label id="lbConContable"> 03 </label>
        </p>
        <p>
            <label>Ciudad: </label>   
            <% =Html.DropDownList ("ddCiudad") %>
            <label>Punto de entrega: </label>
            <%= Html.DropDownList("ddPuntosEntrega") %>

        </p>
        <p>
            <input type="submit" value="Siguiente"/>
        </p>
        <p>
             <%= Html.ActionLink("Menu opciones" , "Menu") %>
        </p>
   <%} %>

Upvotes: 0

Views: 121

Answers (1)

Adauto
Adauto

Reputation: 569

Pass your model to the View:

var pedidos = new Pedidos { division = "teste" };
return View(pedidos);

then tell the view what is its model:

<%@ Language="C#" Inherits="System.Web.Mvc.ViewPage<MvcProject.Models.Pedidos>" %>

and expect it on your action method

public ActionResult  EntradaPedidos(Pedidos miPedido) {
         var division = miPedido.division

Upvotes: 1

Related Questions