locked
two tables problem IN MVC using ADO.NET Entity data model RRS feed

  • Question

  • User-1067283520 posted

    my application have two tables. TableA and TableB

    TableA have one record

    ID   StudentName    Age

    1       MARK               20

    I use selectlist to select  StudentName .

    ViewData["StudentName"] = new SelectList(_db.StudentSet.ToList(), "StudentName", "StudentName");

    and then add to TableB. for this case , for me is success, but I also want to add the"Age" into TableB on same time.

    I don't know how to do it. pleasesupport

    Thanks!

    Tuesday, April 6, 2010 8:37 AM

Answers

  • User197322208 posted

    new SelectList(_db.StudentSet.ToList(), "StudentName", "ID");

    when inserting to table B, retrieve Student from StudentID (StudentSet.Where()) and put studentname and age

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 6, 2010 4:21 PM
  • User-2115483147 posted

    and studentname and age should put where?

     

    In the 'controller', please split this code,

    insert B vlaues(baba,baba)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 9, 2010 1:22 AM

All replies

  • User197322208 posted

    new SelectList(_db.StudentSet.ToList(), "StudentName", "ID");

    when inserting to table B, retrieve Student from StudentID (StudentSet.Where()) and put studentname and age

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 6, 2010 4:21 PM
  • User-1067283520 posted

    new SelectList(_db.StudentSet.ToList(), "StudentName", "ID");

    when inserting to table B, retrieve Student from StudentID (StudentSet.Where()) and put studentname and age

    where should use (StudentSet.Where())? ,and studentname and age should put where?

    would you mind provide more details.

    Thanks

     

    Tuesday, April 6, 2010 9:53 PM
  • User-2115483147 posted

    and studentname and age should put where?

     

    In the 'controller', please split this code,

    insert B vlaues(baba,baba)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 9, 2010 1:22 AM