Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6
This is the forum to discuss the Wrox book ASP.NET 2.0 Instant Results by Imar Spaanjaars, Paul Wilton, Shawn Livermore; ISBN: 9780471749516
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 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 November 9th, 2009, 12:59 AM
Authorized User
 
Join Date: Sep 2009
Posts: 24
Thanks: 3
Thanked 0 Times in 0 Posts
Default Multiple category for a product.

how can i assign multiple category for a products when adding products as an admin .
 
Old November 9th, 2009, 12:52 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

You need to create a junction table like ProductCategories that keeps track of the IDs of the products and of the categories. Then in the Edit page for a product you can get the categories, bind them to a CheckBoxList, and preselect the ones that were previously selected. On save, you need to clear all records from the junction, and then insert the ones that are selected in the CheckBoxList.

This is just a general overview, but i hope you get the idea.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old November 13th, 2009, 12:24 AM
Authorized User
 
Join Date: Sep 2009
Posts: 24
Thanks: 3
Thanked 0 Times in 0 Posts
Default Not able to preselect

thanks for idea,
but i am not getting my checkbox list preselect
Code:
 while (dr.Read())
        {
            ListItem currentcheckbox = (ListItem)CheckBoxList1.Items.FindByValue(dr["catId"].ToString());
            if (currentcheckbox != null)
            {
                currentcheckbox.Selected = true;

            }
while there is value in dr but list item is always null
 
Old November 13th, 2009, 04:08 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Does the CheckBoxList already contain items at this stage? Maybe you need to call DataBind() on it first?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old November 13th, 2009, 08:24 AM
Authorized User
 
Join Date: Sep 2009
Posts: 24
Thanks: 3
Thanked 0 Times in 0 Posts
Default thanks

thanks,
actually i was binding checkboxlist with datasource,which was not working
but bind by code working thanks





Similar Threads
Thread Thread Starter Forum Replies Last Post
dropdownlist with heading for each category debjanib ASP.NET 2.0 Basics 5 May 16th, 2007 04:19 PM
Add category on Blog highspeedwire BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 3 January 26th, 2007 05:35 PM
Changing Category and/or News order seanmayhew BOOK: ASP.NET Website Programming Problem-Design-Solution 1 March 25th, 2005 01:46 PM
Need help with creating a Parent Category seanmayhew BOOK: ASP.NET Website Programming Problem-Design-Solution 2 November 13th, 2004 06:20 PM
Listing Category then Items harpua Classic ASP Professional 3 December 12th, 2003 11:47 AM





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