Sending Parent Key to Controller

2 posts, 0 answers
  1. Deamon
    Deamon avatar
    8 posts
    Member since:
    Nov 2012

    Posted 07 Nov 2014 Link to this post

    I'm using MVC5.

    I haven't been able to find an example of modifying parent / child or header / detail type of situation.

    Currently I have a ViewModel that contains single data from a db record which is the parent or header info.  

    The ViewModel also contains an IEnumerable of the child record type.

    In the view I have elements of the header or parent data and a Grid for the child data.  How do I send the parent key when doing, say, a "create" of new data in the grid after save is pressed.

    The grid is setup to use Ajax and updates are done in Batch.  

    The issue is that I see how I can bind the columns to the child records, but how do I get the parent id sent when "save" is pressed?

    Thanks in advance.

  2. Petur Subev
    Petur Subev avatar
    1882 posts

    Posted 11 Nov 2014 Link to this post

    Hello Daemon,

    Basically if the variable is coming from the MVC Model inside the view then you can do it like this:

    .Update(up=>up.Action("UpdatePerson","Home", new { parentId = Model.TheID}))

    If for some reason the above does not help or the variable should be resolved at run time then you can use the approach from here.

    Kind Regards,
    Petur Subev

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top