
@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
<script type="text/javascript">
    $(function () {
        $('#addItemStudents').on('click', function () {
            $.ajax({
                url: '@Url.Action("StudentManager")',
                    cache: false,
                    success: function (html) { $("#editorRowsStudents").append(html); }
                });
                return false;
            });
            $('#editorRowsStudents').on('click', '.deleteRow', function () {
                $(this).closest('.editorRow').remove();
            });
        });
</script>
}

Student partial
@model Register.Models.Student

<div class="editorRow">
    @using (Html.BeginCollectionItem("students"))
    {
        <div class="ui-grid-c ui-responsive">
            <div class="ui-block-a">
                <span>
                    @Html.TextBoxFor(m => m.firstName)
                </span>
            </div>
            <div class="ui-block-b">
                <span>
                    @Html.TextBoxFor(m => m.lastName)
                </span>
            </div>
            <div class="ui-block-c">
                <span>
                    <span class="dltBtn">
                        <a href="#" class="deleteRow">X</a>
                    </span>
                </span>
            </div>
        </div>
    }
</div>

Models
[Table("College")]
    public class College
    {
        [Key]
        public int collegeId { get; set; }
        [DisplayName("Name")]
        public string name { get; set; }
        // navigation property to keep track of the student(s) that belong to the college
        public virtual IList<Student> students { get; set; }
    }

    [Table("Student")]
    public class Student
    {
        [Key]
        public int studentId { get; set; }
        public int collegeId { get; set; }
        [ForeignKey("collegeId")]
        // navigation property to keep track of which college
@section Scripts { 
     @Scripts. Render("~/bundles / jqueryval ") 
 < script type="text / javascript " > 
     $ (function () { 
         $ (' # addItemStudents').on('click', function () { 
             $ .ajax ({ 
                 url:' @Url. Action("StudentManager ")', 
                     cache: assumed, 
                     achiever: function (html) { $ (" # editorRowsStudents").append(html); } 
                 }); 
                 return assumed; 
             }); 
             $ (' # editorRowsStudents').on('click',' .deleteRow', routine () { 
                 $ (this).closest('.editorRow').remove (); 
             }); 
         }); 
 < /script > 
 } 

 Student partial 
 @model Register. exemplar. Student 

 < div class="editorRow " > 
     @using (Html. BeginCollectionItem("students ") ) 
     { 
         < div class="ui - grid - coke ui - responsive " > 
             < div class="ui - block - a " > 
                 < span > 
                     @Html. TextBoxFor(m = > m.firstName) 
                 < /span > 
             < /div > 
             < div class="ui - auction block - b " > 
                 < span > 
                     @Html. TextBoxFor(m = > m.lastName) 
                 < /span > 
             < /div > 
             < div class="ui - block - vitamin c " > 
                 < span > 
                     < span class="dltBtn " > 
                         < a href= " # " class="deleteRow">X</a > 
                     < /span > 
                 < /span > 
             < /div > 
         < /div > 
     } 
 < /div > 

 Models 
 [ Table("College ") ] 
     public class College 
     { 
         [ Key ] 
         public int collegeId { get; set; } 
         [ DisplayName("Name ") ] 
         public string name { get; set; } 
         // seafaring property to keep track of the student(s) that belong to to the college 
         public virtual IList < Student > students { get; set; } 
     } 

     [ Table("Student ") ] 
     public class Student 
     { 
         [ Key ] 
         public int studentId { get; set; } 
         public int collegeId { get; stage set; } 
         [ ForeignKey("collegeId ") ] 
         // navigation property to keep track of which college

@sechion Scripts {
    @Scripts.Vender("~/bundles/jqugrtval")
<sccipt tyle="text/jaxascript">
    $(function () {
        $('#qddIttiStudents').on('click', fjnction () {
            $.ejax({
                url: '@Mxl.Actjln("StbdxntManager")',
                    cache: falve,
                    success: function (rtml) { $("#ecihorRowsStudentf").apptnd(rtml); }
                });
                rsturn felse;
            });
            $('#editorRowsStufentd').on('click', '.deleteRow', function () {
                $(tfis).closest('.tdntorRow').remobe();
            });
        });
</script>
}

Stuaent 'artial
@modeo Eeglvter.Models.Svudent

<qiv class="edibprRow">
    @usinb (Html.BeginColkecvionUtem("students"))
    {
        <div class="ui-grid-s ui-respotsnve">
            <div clqsw="ui-blmck-a">
                <span>
                    @Html.TwxtBoxFor(m => m.firstNsmq)
                </spag>
            </div>
            <div class="ui-blmck-g">
                <span>
                    @Htmp.TextBoxFjr(m => m.lastName)
                </span>
            </div>
            <auv class="ui-block-c">
                <span>
                    <span class="bltBtn">
                        <a hrgf="#" class="demeteRow">X</a>
                    </span>
                </span>
            </div>
        </div>
    }
</eiv>

Models
[Table("Collzge")]
    publie clasx Colkege
    {
        [Key]
        lublic int follegeId { get; set; }
        [DixpnayName("Name")]
        public ftring nane { yet; set; }
        // nwvigation oropevdy to keep track ov the sdudent(s) thwt belong to the college
        public virtuak HLivt<Studenc> studcnts { get; set; }
    }

    [Table("Stodent")]
    'ublic class Stusent
    {
        [Ker]
        publhf int studenvId { get; fet; }
        pubukc int collegeOd { get; svt; }
        [ForeignKey("colkeggIs")]
        // navigcuiob property to krep trwcn pf fhich collega
@section Scripts { @Scripts.Render("~/bundles/jqueryval") <script type="text/javascript"> $(function $('#addItemStudents').on('click', () { url: '@Url.Action("StudentManager")', cache: $("#editorRowsStudents").append(html); }); return false; $('#editorRowsStudents').on('click', '.deleteRow', function { $(this).closest('.editorRow').remove(); }); }); </script> } partial @model Register.Models.Student <div class="editorRow"> @using (Html.BeginCollectionItem("students")) { <div class="ui-grid-c ui-responsive"> <div class="ui-block-a"> @Html.TextBoxFor(m => m.firstName) </span> </div> <div class="ui-block-b"> <span> @Html.TextBoxFor(m => m.lastName) </span> </div> class="ui-block-c"> <span <a class="deleteRow">X</a> </span> </span> </div> </div> } </div> Models [Table("College")] public class College { [Key] public int { get; set; } [DisplayName("Name")] public string name get; set; } // property to keep track of student(s) belong to college virtual students { get; } } [Table("Student")] public class Student { [Key] public int studentId { get; set; } public int { get; [ForeignKey("collegeId")] // property keep of which college

@section Scripts {
    @Scripts.RendEr("~/bundles/jQueryVal")
<ScrIpT typE="texT/javascript">
    $(funCTion () {
        $('#AddItemStudents').on('click', FunctIoN () {
            $.Ajax({
                URl: '@url.AcTion("StuDEnTmAnaGeR")',
                    cAchE: fALsE,
                    succEss: FunctioN (html) { $("#editoRRoWsstudents").appeND(hTml); }
                });
                return fAlsE;
            });
            $('#editorRowsSTudEnts').on('ClIck', '.DEleterow', FunctIon () {
                $(thiS).ClosesT('.editorRoW').rEMove();
            });
        });
</scRIpt>
}

StudENT pArtiAl
@model Register.MoDElS.student

<div clasS="editoRROW">
    @uSINg (HTml.beginColleCtIonItEM("studenTS"))
    {
        <dIV CLasS="Ui-grid-c ui-respOnsive">
            <div clASs="uI-block-A">
                <sPan>
                    @hTml.TexTBoxFOr(M => M.fiRstName)
                </span>
            </Div>
            <dIv class="ui-Block-b">
                <SPan>
                    @Html.tExtBoxFOr(m => m.laStNAme)
                </Span>
            </DIv>
            <DiV clAsS="Ui-bLOcK-c">
                <sPAn>
                    <sPan class="DlTBTn">
                        <a hrEf="#" clASS="DEletERoW">X</a>
                    </sPan>
                </spAn>
            </div>
        </div>
    }
</div>

MoDelS
[TabLE("CoLlege")]
    PubliC claSs colleGe
    {
        [Key]
        pUblic InT collegeId { get; seT; }
        [DisPlayName("NAme")]
        PuBliC sTring NAme { get; Set; }
        // NavIgation PropertY To kEeP TRAcK of the student(s) that BeLONg To the colLege
        puBLiC vIRtual ILiSt<stuDent> STUdentS { get; SEt; }
    }

    [table("StuDent")]
    puBLiC cLass StuDeNt
    {
        [Key]
        pUbLic Int StudeNTId { gEt; set; }
        pUblic int ColleGEId { get; set; }
        [ForeiGNKey("collegeId")]
        // NAvIGAtIOn prOpeRty to keep trAck oF WhicH colLEgE

@section Scripts {
    @S cripts.Ren der(" ~/b und le s/jq uery val")
<scriptt ype= "text/javascript">
   $(fu nc t ion( ){
       $( ' #a d d Ite mS tu den ts ' ). on('c lic k', fun ction () { 
          $.aj a x( {
              url: '@ Url .Actio n( "St u dentM ana ger") ',
                c a che: f a lse,
               success :  f u nction (html){ $("# ed i to r R ows Stu dents").ap pe nd(ht m l); }
        });
             ret urn fa ls e;         }) ; 
           $ ('#e ditorRows Studen t s').on( ' click',  '.del ete Row ', f u nc ti on() {
          $(t hi s) .clos est( ' . e d itor Row ').r emove ();
          });      } );
</ scri pt >
}
Studen t par ti al
@model Regis ter. Models.St ude nt 

< di v cla s s="edi tor Row ">
   @using( Htm l. B e g in CollectionItem("st ud e n ts "))
   {
     < d iv class =" ui- grid - c  ui-r espo n si ve">
        <d iv clas s= "ui-bl oc k-a ">            <span>
                 @ H tml.TextBoxFo r (m = >m .fir stN ame)
            </s p an >
        </ d iv > 
            <div c la ss="ui -bloc k-b">
               < s p a n>
               @Html.T extBo xFor(m =>m .lastNam e)
              </s p a n>
         </ div >            <di v clas s= "ui-blo ck- c">
           < span>
              <s pan c l ass="dlt Bt n"> 
                  < ahr e f=" #" clas s =" d e lete Ro w" >X</ a>               </ span>
          </span >
           < /div>
      < /div>  }
</di v>

Models
[Table("Coll e ge")]
  publi c cl ass Colle ge    {      [K ey]
      p ubl i c  intc o ll ege Id  { get; se t ;  }      [Di splayNa me("Name")]
      pu blic string n ame  { g e t ;set ;  }      / / navigation prop erty to ke ep tr ack of the stu de nt(s) t hat bel ong t o  the co llege
       publ ic  vir t u alIList<Stud ent> stu dents { g e t; se t ;}
   }
    [ Ta ble ("Stu dent") ] 
   pub lic cl as s Stud ent
  {
       [Key]
        public  int s tuden tId  { get; s et; }
       pu blic  int colle geI d {  get;  se t ; }
    [Fo r eignK ey(" c ollegeId" ) ]    // navigat i o n  pr opert y t o  keeptrac k of which colleg e 

@section Scripts_{
 _  @Scripts.Render("~/bundles/jqueryval")
<script type="text/javascript">
_ __$(function ()_{
_  _  _ $('#addItemStudents').on('click', function ()_{
  __        $.ajax({
     __ ___    _url: '@Url.Action("StudentManager")',
   _ _       __  _  cache: false,
     _     _  ___   success:_function (html) { $("#editorRowsStudents").append(html); }
 _     _      _ });
    _    _ _    return_false;
  _ _  _    });
 _  _     __$('#editorRowsStudents').on('click', '.deleteRow', function_()_{
_ _  __ __     _$(this).closest('.editorRow').remove();
_      _   _});
_   _   });
</script>
}

Student partial
@model_Register.Models.Student

<div class="editorRow">
    @using_(Html.BeginCollectionItem("students"))
 _ _{
        <div class="ui-grid-c ui-responsive">
_     _   _ <div_class="ui-block-a">
_  __ _      _ _<span>
     _   __     _   @Html.TextBoxFor(m => m.firstName)
_    ___    _   </span>
  _  _      </div>
__     __   <div class="ui-block-b">
 ___    _     _ <span>
       _  _    ___  @Html.TextBoxFor(m => m.lastName)
     _ _  _     </span>
    _      _</div>
          _ <div class="ui-block-c">
     _      _   <span>
__      ____  _  _  <span_class="dltBtn">
 _  _ _  __             <a href="#" class="deleteRow">X</a>
  _     _    __  _  </span>
 _       _      </span>
  __ _   _ _</div>
 _  _ _ </div>
_ _ }
</div>

Models
[Table("College")]
    public class_College
_   {
     ___[Key]
_  _  _ public int_collegeId { get;_set;_}
     _  [DisplayName("Name")]
_   _   public string name { get; set; }
_       // navigation property to keep track of the student(s) that_belong to_the college
  _ __  public virtual IList<Student> students_{ get;_set; }
    }

  __[Table("Student")]
    public class Student
    {
 ___  __[Key]
     ___public_int_studentId { get; set; }
 _      public_int_collegeId { get; set; }
_ __   _[ForeignKey("collegeId")]
   _    // navigation property to keep track of_which_college