c# - How to select data via partial view -


i have partial view returns list of users address's, need user able select one, when press "submit" along other details takes details selected address returns controller, there know how assign want. how this? examples , appreciated

here controller creating order, view beneath;

[httppost]     public actionresult addressandpayment(formcollection values, string id)     {          var order = new order();         tryupdatemodel(order);          //sets date , username         order.username = user.identity.name;         order.orderdate = datetime.now;           //order gets saved         storedb.orders.add(order);                 storedb.savechanges();                   //order gets processed                 var cart = shoppingcart.getcart(this.httpcontext);                 cart.createorder(order);                  //save again, total not saving until                 storedb.savechanges();           return redirecttoaction("complete",                     new { id = order.orderid });     } 

view

@model t_shirt_company_v3.models.order  @{     viewbag.title = "address , payment"; }    @using (html.beginform()) {     @html.antiforgerytoken()      @html.hiddenfor(x => x.orderid)     @html.hiddenfor(x => x.orderdate)     @html.hiddenfor(x => x.paymenttransactionid)     @html.hiddenfor(x => x.total)     @html.hiddenfor(x => x.username)      <div class="form-horizontal">         <h2>address , payment</h2>         <hr />         @html.validationsummary(true, "", new { @class = "text-danger" })           @{html.renderaction("listofaddresses", "checkout");}           <h2>select postage type</h2>           @html.enumdropdownlistfor(model => model.postagelist, "-- please select postage type --")           <h2>payment</h2>          <div class="form-group">             @html.labelfor(model => model.carddetails.fullname, htmlattributes: new { @class = "control-label col-md-2" })             <div class="col-md-10">                 @html.editorfor(model => model.carddetails.fullname, new { htmlattributes = new { @class = "form-control" } })                 @html.validationmessagefor(model => model.carddetails.fullname, "", new { @class = "text-danger" })             </div>         </div>          <div class="form-group">             @html.labelfor(model => model.carddetails.cardno, htmlattributes: new { @class = "control-label col-md-2" })             <div class="col-md-10">                 @html.editorfor(model => model.carddetails.cardno, new { htmlattributes = new { @class = "form-control" } })                 @html.validationmessagefor(model => model.carddetails.cardno, "", new { @class = "text-danger" })             </div>         </div>          <div class="form-group">             @html.labelfor(model => model.carddetails.cardexpiremonth, htmlattributes: new { @class = "control-label col-md-2" })             <div class="row">                 <div class="col-md-1">                     @html.editorfor(model => model.carddetails.cardexpiremonth, new { htmlattributes = new { @class = "form-control" } })                     @html.validationmessagefor(model => model.carddetails.cardexpiremonth, "", new { @class = "text-danger" })                 </div>                 <div class="col-md-1">                     @html.editorfor(model => model.carddetails.cardexpireyear, new { htmlattributes = new { @class = "form-control" } })                     @html.validationmessagefor(model => model.carddetails.cardexpireyear, "", new { @class = "text-danger" })                 </div>              </div>          </div>          <div class="form-group">             @html.labelfor(model => model.carddetails.cvc, htmlattributes: new { @class = "control-label col-md-2" })             <div class="col-md-10">                 @html.editorfor(model => model.carddetails.cvc, new { htmlattributes = new { @class = "form-control" } })                 @html.validationmessagefor(model => model.carddetails.cvc, "", new { @class = "text-danger" })             </div>         </div>          <div class="form-group">             <div class="col-md-offset-2 col-md-10">                 <input type="submit" value="create" class="btn btn-default" />             </div>         </div>     </div> } 

partial view

@model ienumerable<t_shirt_company_v3.models.deliveryaddress>  @foreach (var item in model) {     <div style="width: 180px">         <div class="thumbnail">              <p>@html.displayfor(modelitem => item.firstname) @html.displayfor(modelitem => item.lastname) </p>              <p>@html.displayfor(modelitem => item.address)</p>              <p>@html.displayfor(modelitem => item.city)</p>              <p>@html.displayfor(modelitem => item.postalcode)</p>              <p>@html.displayfor(modelitem => item.country)</p>         </div>     </div> } 

address class

    public class deliveryaddress     {         [key]         [scaffoldcolumn(false)]         public int adressid { get; set; }          [scaffoldcolumn(false)]         public string usersaddress { get; set; }          [required]         [stringlength(16, errormessage = "your name long")]         [display(name = "first name")]         public string firstname { get; set; }          [required(errormessage = "your last name required.")]         [stringlength(16, errormessage = "last name long.")]         [display(name = "last name")]         public string lastname { get; set; }          [required(errormessage = "address required.")]         public string address { get; set; }          [required(errormessage = "city required.")]         public string city { get; set; }          [required(errormessage = "postcode required.")]         [display(name = "post code")]         public string postalcode { get; set; }          [required(errormessage = "country required.")]         public string country { get; set; }          [required(errormessage = "phone home number required.")]         [display(name = "home telephone")]         public string phone { get; set; }          [required(errormessage = "phone mobile number required.")]         [display(name = "mobile")]         public string mobile { get; set; }      } } 


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -