1

So im obtaining a dropdown list via Knockout and a array json result, like this

@Html.DropDownListFor(m => m.SelectedGodClubID,
    (SelectList)Model.clubIDlistItems, new
    {
        id = "ctid",
        data_bind = " options: DynamicClublist, optionsText: 'ClubType', optionsValue: 'ctid'",        
    })

I would now like to bind this to a string to then use on another controller, and im stuggleing to figure this out

Im trying to use this and then read the vlaue

public static string selectedNewClubID(loggedinViewModel model, clubID[] clubid, string exit)
{
    exit = model.SelectedGodClubID = clubid[int.Parse(model.SelectedGodClubID) - 1].Club_ID;

    return exit;
}

}

any help ?

tereško
  • 58,060
  • 25
  • 98
  • 150
  • Hard to understand your problem as described in your question, possible to reword or even better if you can share a jsfiddle. – SBirthare Oct 21 '14 at 09:36
  • i just want to obatin the slected value –  Oct 21 '14 at 09:43
  • maybe im missing a auto postback function ? –  Oct 21 '14 at 09:54
  • See if this helps http://stackoverflow.com/questions/5783344/on-select-change-event-html-dropdownlistfor – SBirthare Oct 21 '14 at 10:02
  • no luck, all I want to do is bind the selected item to a contraller variable –  Oct 21 '14 at 11:19
  • 1
    Your description is confusing to me. I believe you want to capture the selected value (handle onChange event in JS code) and send it to controller (using Ajax). Is it correct? – SBirthare Oct 21 '14 at 11:40
  • @SBirthare sounds just what I am needing yes –  Oct 21 '14 at 12:06
  • @SBirthare the only part im doing any differently would bet the list data_bind from a knockout.js array, hope you can help –  Oct 21 '14 at 12:10
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/63407/discussion-between-tim-dime-and-sbirthare). –  Oct 21 '14 at 12:15
  • looks like the problem your having is mixing server side and client side code. what does your clientside viewmodel look like? – Nathan Fisher Oct 27 '14 at 00:32
  • no its all working now –  Oct 27 '14 at 12:36

0 Answers0