Wrox Programmer Forums
|
BOOK: Professional ASP.NET MVC 1.0 ISBN: 978-0-470-38461-9
This is the forum to discuss the Wrox book Professional ASP.NET MVC 1.0 by Rob Conery, Scott Hanselman, Phil Haack, Scott Guthrie; ISBN: 978-0-470-38461-9
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET MVC 1.0 ISBN: 978-0-470-38461-9 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 16th, 2009, 10:08 AM
Authorized User
 
Join Date: Mar 2009
Posts: 15
Thanks: 2
Thanked 0 Times in 0 Posts
Default Filtering Data with a Selectbox (Chapter 7 P.295)

I've tried to get this to work but I get the following error.
There is no ViewData item with the key 'CategoryID' of type 'IEnumerable<SelectListItem>'.
The Controller looks like this:
public ActionResult ProductByCategory(int id)
{
NorthwindDataContext db = new NorthwindDataContext();
IList<Product> products = (from p in db.Products
where p.CategoryID == id
select p).ToList();
var categories = db.Categories;
ViewData["CategoryID"] = new SelectList(categories, "CategoryID", "CategoryName");
if (Request.IsAjaxRequest())
{
return View("ProductSearchResults", products);
}
else
{
return View("ProductSearch", products);
}
}
and the View looks like this:

<form action="<%=Url.Action("ProductSearch") %>" method="post" id="jform">
<%= Html.DropDownList("CategoryID")%>
<%=Html.TextBox("query",null, new {size=40}) %>
<input type="submit" id="jsubmit" value="Go" />
</form>

Does anyone have a full listing?





Similar Threads
Thread Thread Starter Forum Replies Last Post
chapter9, 295. pas BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 5 October 1st, 2008 04:55 AM
Filtering XML data aldwinenriquez XSLT 7 August 25th, 2008 03:24 AM
data filtering from combobox MAKO C# 4 June 1st, 2006 03:54 AM
Chapter 4 - Filtering example pehrig BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 6 September 24th, 2004 02:39 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.