p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > ASP.NET and ASP > ASP.NET 3.5 > BOOK: Professional ASP.NET MVC 1.0 ISBN: 978-0-470-38461-9
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 16th, 2009, 11:08 AM
Authorized User
Points: 68, Level: 1
Points: 68, Level: 1 Points: 68, Level: 1 Points: 68, Level: 1
Activity: 5%
Activity: 5% Activity: 5% Activity: 5%
 
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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

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 05:55 AM
Filtering XML data aldwinenriquez XSLT 7 August 25th, 2008 04:24 AM
data filtering from combobox MAKO C# 4 June 1st, 2006 04:54 AM
Chapter 5 VWD app.: Filtering Data Dynamically BigOcean BOOK: Wrox's SQL Server 2005 Express Edition Starter Kit ISBN: 978-0-7645-8923-2 2 May 5th, 2006 09:36 AM
Chapter 4 - Filtering example pehrig BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 6 September 24th, 2004 03:39 PM



All times are GMT -4. The time now is 05:35 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc