Per writes "I wonder if there's a smarter way to categorize data in ASP.NET, than the way I'm doing it in classic ASP.I need to graphically show data in a categorized way, like this:Category Product ProductCategory Product Product ProductCategory ProductIs there a smart SQL query that can help me do that??I have 2 tables in SQL server, one called Categories and the other Products.Categories table----------------PK_ID int (primary key, identity)Name nvarchar (50)Products table----------------PK_ID int (prim. key, identity)FK_CatId int (the PK_ID of Categories table)Name nvarchar (50)
I normally pull all of the categories out and store them in array. Then I loop through that array and for each element in it, I'd runa SQL-query to get all of the products associated with that element.' Pseudo VBScript-code ' Select all categories an put them in an array and loop through it.catArray(pkid,name) = SELECT PK_ID,Name FROM CategoriesFOR i = lBound(catArray) to uBound(catArray) response.write catArray(name,i) proArray(name) = SELECT name FROM Products WHERE FK_CatId = catArray(pkid,i) FOR p = lbound(proArray) to uBound(proArray) response.write "nbsp;nbsp;nbsp;" & proArray(name,p) NEXTNEXT
I know that this isn't the most beautifull way to do it, so can you please help me??"