Hi everyone, I'm trying to create subcategories in the Commerce StarterKit. A part of the job works but i think i don't have enough knowledge to go further. I'm trying to solve my last problem for two days. Right now I'm able to display subcategories in the
productlist page depending of the selected category but i'm not able to display products that make part of one subcategory. I added this two stored procedures: CREATE PROCEDURE CMRC_ProductsbySubCategory ( @SubCategoryId int ) AS SELECT ProductID, ModelName,
UnitCost, ProductImage FROM CMRC_Products WHERE SubCategoryID = @SubCategoryID ORDER BY ModelName, ModelNumber GO and CREATE PROCEDURE CMRC_ProductSubCategoryList ( @CategoryID int ) AS SELECT SubCategoryID, CategoryID, SubCategoryName FROM CMRC_SubCategories
WHERE CategoryId = @CategoryId ORDER BY SubCategoryID ASC GO I added one new table called CMRC_SubCategories containing three columns: CategoryId, SubcategoryId and SubCategoryName. I created a new control _Subcategory.ascx: <script runat="server"> Sub Page_Load(ByVal
sender As Object, ByVal e As EventArgs) Dim categoryId As Integer = CInt(Request.Params("CategoryID")) ' Obtain products and databind to an asp:datalist control Dim productCatalogue As ASPNET.Starterkit.Commerce.ProductsDB = New ASPNET.Starterkit.Commerce.ProductsDB()
MyList.DataSource = productCatalogue.GetProductSubCategories(CategoryID) MyList.DataBind() End Sub </script>
This control is integrated in ProductList.aspx The script is: Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) ' Obtain categoryId from QueryString Dim categoryId As Integer = CInt(Request.Params("CategoryID")) ' Obtain products and databind to an
asp:datalist control Dim productCatalogue As ASPNET.Starterkit.Commerce.ProductsDB = New ASPNET.Starterkit.Commerce.ProductsDB() MyList.DataSource = productCatalogue.GetProducts(CategoryId) MyList.DataBind() End Sub the html part added is:
I finally modified the ProductDB.vb with this function: Public Function GetProductSubCategories(ByVal CategoryID As Integer) As SqlDataReader ' Create Instance of Connection and Command Object Dim myConnection
As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString")) Dim myCommand As SqlCommand = New SqlCommand("CMRC_ProductSubCategoryList", myConnection) ' Mark the Command as a SPROC myCommand.CommandType = CommandType.StoredProcedure
' Add Parameters to SPROC Dim parameterCategoryID As SqlParameter = New SqlParameter("@CategoryID", SqlDbType.Int, 4) parameterCategoryID.Value = categoryID myCommand.Parameters.Add(parameterCategoryID) ' Execute the command myConnection.Open() Dim result
As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection) ' Return the datareader result Return result End Function and the function getproducts becomes: Public Function GetProducts(ByVal SubCategoryID As Integer) As SqlDataReader ' Create
Instance of Connection and Command Object Dim myConnection As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString")) Dim myCommand As SqlCommand = New SqlCommand("CMRC_ProductsBySubCategory", myConnection) ' Mark the Command
as a SPROC myCommand.CommandType = CommandType.StoredProcedure ' Add Parameters to SPROC Dim parameterSubCategoryID As SqlParameter = New SqlParameter("@SubCategoryID", SqlDbType.Int, 4) parameterSubCategoryID.Value = SubcategoryID myCommand.Parameters.Add(parameterSubCategoryID)
' Execute the command myConnection.Open() Dim result As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection) ' Return the datareader result Return result End Function I also created a new component called ProductSubcategoriesDB.vb Does
anyone have an idea of what is wrong ??? Thank you for any help
Hi I am going to be attempting to do the same thng adding in subgategories into the commerce starter kit, I am using c# instead of vb for the coding. I think your on the right track but i am wondering if the in the selected item template instead of using hyperlinks,
inbedding another datalist. I am also trying to add paging into the commerce starter kit, but i am having problems with converting the SqlDataReader into a IColllection based class so that getting the page count or determing the last page is possible. Maybe
we can help each other, I am unsure whether or not you are wanting to do paging but i know, it is a requirment for me to implement it. Hope this infomation helps. Daffy :o)
divos
Member
95 Points
19 Posts
creating subcategories
Nov 24, 2004 11:19 AM|LINK
divos
Member
95 Points
19 Posts
Re: creating subcategories
Dec 02, 2004 01:39 PM|LINK
divos
Member
95 Points
19 Posts
Re: creating subcategories
Jan 17, 2005 06:41 AM|LINK
DaffyDuck
Member
15 Points
4 Posts
Re: creating subcategories
Feb 01, 2005 04:21 PM|LINK