is there way call generic function, tell me value of dropdown list: hide oldstatusid. so, can see in db:
jobstatusid| status name 4 | prospect/waiting proposal
when change status, example "lost", , click save, program keeps id=4, instead of id=2..
here view:
@using system.collections.concurrent @model dataaccess.partialclass.statuspipelinemerge @{ viewbag.title = "edit"; } <h2>edit</h2> @using (html.beginform()) { @html.antiforgerytoken() <div class="form-horizontal"> <h4>adeccoview</h4> <hr /> @html.validationsummary(true, "", new { @class = "text-danger" }) @html.hiddenfor(model => model.pipelineid) @*@html.validationsummary(true, "", new { @class = "text-danger" }) @html.hiddenfor(model => model.statusid)*@ <div class="form-group"> @html.labelfor(model => model.projectvaluemoney, htmlattributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @html.editorfor(model=>model.projectvaluemoney, new { htmlattributes = new { @class = "form-control" } }) @*@html.validationmessagefor(model => model.projectvaluemoney, "", new { @class = "text-danger" })*@ </div> </div> <div class="form-group"> @html.labelfor(model=>model.projectvaluehr, htmlattributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @html.editorfor(model => model.projectvaluehr, new { htmlattributes = new { @class = "form-control" } }) @html.validationmessagefor(model => model.projectvaluehr, "", new { @class = "text-danger" }) </div> </div> <div class="form-group"> @html.labelfor(model => model.commentpipeline, htmlattributes: new {@class = "control-label col-md-2"}) <div class="col-md-10"> @html.editorfor(model => model.commentpipeline, new {htmlattributes = new {@class = "form-control"}}) @html.validationmessagefor(model => model.commentpipeline, "", new {@class = "text-danger"}) </div> </div> <div class="form-group"> @html.labelfor(model => model.fcoid, htmlattributes: new {@class = "control-label col-md-2"}) <div class="col-md-10"> @html.editorfor(model => model.fcoid, new {htmlattributes = new {@class = "form-control"}}) @html.validationmessagefor(model => model.fcoid, "", new {@class = "text-danger"}) </div> </div> <div class="form-group"> @html.labelfor(model => model.oldstatusid, htmlattributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @html.editorfor(model => model.oldstatusid, new { htmlattributes = new { @class = "form-control" } }) @html.validationmessagefor(model => model.oldstatusid, "", new { @class = "text-danger" }) </div> </div> <div class="form-group"> @html.labelfor(model => model.clientid, "client name", htmlattributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @html.dropdownlist("clientid", null, htmlattributes: new { @class = "form-control" }) @html.validationmessagefor(model => model.clientid, "", new { @class = "text-danger" }) </div> </div> <div class="form-group"> @html.label("field of cooperation", new { @class = "control-label col-md-2" }) <div class="col-md-10"> @html.dropdownlist("fco", null, htmlattributes: new { @class = "form-control" }) @html.validationmessagefor(model => model.fconame, "", new { @class = "text-danger" }) </div> </div> <div class="form-group"> @html.label("status", new {@class = "control-label col-md-2"}) <div class="col-md-10"> @html.dropdownlist("status2", null, htmlattributes: new {@class = "form-control"}) </div> </div> <div class="form-group"> <div class="col-md-offset-2 col-md-10"> <input type="submit" value="save" class="btn btn-default"/> </div> </div> </div> } <div> @html.actionlink("back list", "index") </div>
here controller - edit (get&post)
//// get: adeccoviews/edit/5 public actionresult edit(int? id) { if (id == null) { return new httpstatuscoderesult(httpstatuscode.badrequest); } statuspipelinemerge merge1 = new statuspipelinemerge(); merge1.commentpipeline = db.pipelines.find(id).commentpipeline; merge1.projectvaluehr = db.pipelines.find(id).projectvaluehr; merge1.projectvaluemoney = db.pipelines.find(id).projectvaluemoney; merge1.pipelineid = (int)id; merge1.jobstatusname = statusonid(id); merge1.fcoid = db.pipelines.find(id).fcoid; merge1.oldstatusid = statusidselected(id); // httpcookie cookie = cookiemanager.createcookie("mergepipelinestatus", .createdby.tostring(), adeccoview.createdtimestamp.tostring(), id.tostring()); // response.setcookie(cookie); if (merge1 == null) { return httpnotfound(); } viewbag.clientid = new selectlist(db.clients.orderby(x => x.clientname), "clientid", "clientname", merge1.clientid); //viewbag.comment = new selectlist(db.pipelines, "commentpipeline", merge1.commentpipeline); viewbag.comment = new selectlist(db.pipelines, "pipelineid", "commentpipeline", merge1.commentpipeline); viewbag.projectvaluehr = new selectlist(db.pipelines, "pipelineid", "projectvaluehr", merge1.projectvaluehr); viewbag.projectvaluemoney = new selectlist(db.pipelines, "pipelineid", "projectvaluemoney", merge1.projectvaluemoney); viewbag.fco = new selectlist(db.fcoes, "fcoid", "namefco", merge1.fconame); viewbag.status2 = new selectlist(getjobstatus(statusonid(id)), "jobstatusid", "jobstatusname", merge1.jobstatusname); viewbag.status3 = new selectlist(getjobstatus(statusonid(id)), "jobstatusid", "jobstatusname", merge1.statusid); viewbag.oldstatus = new selectlist(getjobstatus(statusonid(id)), "jobstatusid", "jobstatusid", merge1.oldstatusid); return view(merge1); } //// post: adeccoviews/edit/5 //// protect overposting attacks, please enable specific properties want bind to, //// more details see http://go.microsoft.com/fwlink/?linkid=317598. [httppost] [validateantiforgerytoken] public actionresult edit([bind(include = "status2,status3,id,pipelineid,projectvaluehr,projectvaluemoney,commentpipeline,statusid,jobstatusname,fcoid,clientid,createdtimestamp,createdby,modifiedtimestamp,modifiedby")] statuspipelinemerge merge) { if (modelstate.isvalid) { string controllername = "mergepipelinestatus"; pipeline pipe = new pipeline(); pipelinejobstatu pjs = new pipelinejobstatu(); pipe.pipelineid = merge.pipelineid; pipe.projectvaluehr = merge.projectvaluehr; pipe.projectvaluemoney = merge.projectvaluemoney; employee user1 = session["user"] employee; pipe.createdby = user1.employeed; pipe.commentpipeline = merge.commentpipeline; datetime mydatetime = datetime.now; string sqlformatteddate = mydatetime.tostring("yyyy-mm-dd hh:mm:ss"); pipe.createdtimestamp = convert.todatetime(sqlformatteddate); pipe.clientid = merge.clientid; pipe.fcoid = merge.fcoid; pjs.pipelineid = merge.pipelineid; pjs.jobstatusid = merge.statusid; pjs.createdby = user1.employeed; pjs.createdtimestamp = convert.todatetime(sqlformatteddate); db.pipelines.add(pipe); db.pipelinejobstatus.add(pjs); db.entry(pipe).state = entitystate.modified; db.entry(pjs).state = entitystate.modified; db.savechanges(); cookiemanager.setcookie(consts.cookie_name, 1, "upešno izmenjen task", enumnotificationmessagetype.success, response); return redirecttoaction("index"); } viewbag.status2 = new selectlist(getjobstatus(statusonid(merge.pipelineid)), "jobstatusid", "jobstatusid", merge.jobstatusname); viewbag.status3 = new selectlist(getjobstatus(statusonid(merge.pipelineid)), "jobstatusid", "jobstatusid", merge.statusid); viewbag.clientid = new selectlist(db.clients, "clientid", "clientname", merge.clientid); //viewbag.employeeid = new selectlist(db.employees, "employeed", "name", adeccoview.employeeid); //viewbag.eventtypeid = new selectlist(db.eventtypes, "eventtypeid", "event", merge.eventtypeid); return view(merge); }
so, tryng status2 viewbag, pull out id text/string. thanks!
Comments
Post a Comment