How to insert data into table using asp.net mvc -


i new asp.net mvc , doing project asp.net, want insert data can't run code because parameter supplierid null value (supplierid data have in table).

how can insert these data ??

phoneno,mobileno , faxno data want insert in table.

here code.

model

 public partial class generalinfosmodel {     public int supplierid { get; set; }             public string countrycode { get; set; }     public string taxid { get; set; }            public string phoneno { get; set; }            public string mobileno { get; set; }     public string faxno { get; set; }         } 

control in control have call supplierid table query. problem supplierid null.

       public actionresult contactcompany(int supplierid )     {        // return view();         var model = _organizationrepository.getdatabysupplierid(supplierid );         return view("contactcompany", model);     }     [httppost]        public actionresult contactcompany(tbl_organization model)     {         var orgmodel = _organizationrepository.getdatabysupplierid(model.supplierid);         if (orgmodel != null)         {             orgmodel.phoneno = model.phoneno;                            orgmodel.mobileno = model.mobileno;                             orgmodel.faxno = model.faxno;                            _organizationrepository.update(orgmodel);         }         var orgmodel = _organizationrepository.getdatabysupplierid(model.supplierid);         return view("contactcompany", orgmodel);     } 

view

@using (html.beginform("contactcompany", "contactinformation", formmethod.post, new { id = "supplierid" })) 

{

<div class="col-sm-8 col-md-8">     <div class="panel panel-default">         <div class="panel-body">             <input type="submit" value="@t("_global.btnsave")" class="btn btn-primary" onclick="disablepageform();" />             <div style="padding-top:40px;">             </div>      @html.hiddenfor(a => a.supplierid)                             <div class="form-inline-element margin-none" style="width: 15%;">                 @html.label("", t("phone no. ").tostring(), new { @class = "captionstyle1" })             </div>             <div>                 <div class="editorcontainer">                      @html.devexpress().textbox( settings =>             {                 settings.name = "phonenumbox";                 settings.width = 170;                settings.properties.nulltext = "enter phone number";             }         ).gethtml()                 </div>             </div>                <div style="padding-top:40px;">             </div>              <div class="form-inline-element margin-none" style="width: 15%;">                 @html.label("", t("mobile number ").tostring(), new { @class = "captionstyle1" })             </div>              <div>                 <div class="editorcontainer">                     @html.devexpress().textbox(             settings =>             {                 settings.name = "mobilenumbox";                 settings.width = 170;                 settings.properties.nulltext = "enter mobile number";             }         ).gethtml()                 </div>             </div>              <div style="padding-top:40px;">             </div>              <div class="form-inline-element margin-none" style="width: 15%;">                 @html.label("", t("fax number ").tostring(), new { @class = "captionstyle1" })             </div>              <div>                 <div class="editorcontainer">                     @html.devexpress().textbox(             settings =>             {                 settings.name = "faxnumbox";                 settings.width = 170;                 settings.properties.nulltext = "enter fax number";             }         ).gethtml()                 </div>             </div>             </div>     </div> </div> 

}


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -