title: Problem with ViewData in ASP.NET MVC 3
body: <p>I have following tables in my application:</p>
  
  <p>BookCatalogue</p>
  
  <p>--ID(PK)</p>
  
  <p>--BookName</p>
  
  <p>--AuthorID(FK)</p>
  
  <p>Author</p>
  
  <p>--ID(PK)</p>
  
  <p>--FirstName</p>
  
  <p>--LastName</p>
  
  <p>In Edit view for bookCatalogue I want to display not textbox for ID but list of authors.</p>
  
  <p>This is my code:</p>
  
  <p>Controller</p>
  
  <pre><code>    public ActionResult Edit(int id)
      {
          ViewData["Authors"] = _authorRepository.GetAllAuthors();
          var book = _bookCtalogueRepository.GetBookById(id);
          if (book == null)
              throw new Exception("Book not found");
          return View(book);
      }
  </code></pre>
  
  <p>View(this displays only LastName)</p>
  
  <pre><code>...
          &lt;div&gt;
              @Html.LabelFor(model =&gt; model.Author)
          &lt;/div&gt;
          &lt;div&gt;
              @Html.DropDownList("ID", new SelectList(ViewData["Authors"] as System.Collections.IEnumerable,
           "ID", "LastName" , Model.AuthorID))
          &lt;/div&gt;
  ...
  </code></pre>
  
  <p>I have two problems:</p>
  
  <p>1) How to combine FirstName and Lastname in one DropDownList?</p>
  
  <p>2) When I change LastName and BookName and try to save changes only new BookName is changed.</p>
  
  <p>This is my code for saving changes</p>
  
  <pre><code>    [HttpPost]
      public ActionResult Edit(int id, FormCollection collection)
      {
          var book = _bookCtalogueRepository.GetBookById(id);
          if (TryUpdateModel(book))
          {
              _bookCtalogueRepository.SaveChanges();
              return RedirectToAction("Index");
          }
          else
          {
              ViewData["Genres"] = _genreRepository.GetAllGenres();
              ViewData["Authors"] = _authorRepository.GetAllAuthors();
              return View(book);
          }
      }
  </code></pre>
  
  <p>Thank you.</p>