Monday, 15 March 2010

c# - passing value from Knockoutjs dropdownlist to SQL MVC5 -



c# - passing value from Knockoutjs dropdownlist to SQL MVC5 -

ok have kocokout array populating dropdownlist

var idddl = (from c in db.idlists select new id { id = c.id, id = c.id}).toarray(); var idlist = html.raw(jsonconvert.serializeobject(viewbag.idddl));

i have form submit button

the drop downs bind select.

<div class="form-group" style="padding-top: 0px"> @html.labelfor(m => m.id, new { @class = "col-md-2 control-label" }) <div class="col-md-10"> <select id="idddl" data-bind="options: list, optionstext: 'id'"></select> </div> </div> <input type="submit" class="btn btn-default" value="create" />

on count/register controller have added these register model , added them new applicationuser()

var user = new applicationuser() { username = model.email, email = model.email, clubtype = model.clubtype, userauthoritylevel = model.authtype, clubid = model.clubid };

and registerviewmodel had these added

[display(name = "id")] public string id { get; set; } [display(name = "type ")] public string type { get; set; } [display(name = "authority level ")] public string authtype { get; set; }

i know missing that's maybe simple help welcome, ps sorry poor english language skills

use optionsvalue bind selected item:

<select id="idddl" data-bind="options: list, optionstext: 'id', optionsvalue: 'selectedid'"></select>

c# javascript asp.net sql knockout.js

No comments:

Post a Comment