Click here to Skip to main content
15,896,153 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want data in gridview like this:

CategoryName Subcategory Name
--------------------------------
Abc Abc1,abc2,abc3
Bcs Bcs1,bcs2
def Null / No Record

How can I do that?

okay i want data from database by using single table. i have one table categories in which i have field like categryid, parentid,name. when parentid is 0 then its known by Categories else all other is subCategories.

I Am using asp.net with c# and i want to do this in gridview with using boundfield. for categories i have done but for sub categories i dont have any idea how to do.

subcategories is idedntify by its parentid. in sub categories parentid =categryid
Posted

1 solution

You have to use the Common Table Expression .
Refer the link for more details .
http://blog.sqlauthority.com/2008/07/28/sql-server-simple-example-of-recursive-cte/[^]
 
Share this answer
 
Comments
DimpalPindoriya 29-Jan-13 7:44am    
thanks vinodh i can do this also by using inside datalist in item template of gridview but i dnt know hw to pass the gridview item id as a parameter in datalist..
if you have knowledge about it then please help me..
Vinodh.B 29-Jan-13 8:07am    
Your above comments are unclear. Could you explain step by step exactly what is your need or how to display the data .
DimpalPindoriya 30-Jan-13 5:58am    
its okay now i solved my problem.,
Vinodh.B 30-Jan-13 6:07am    
anyways if my solution had helped you you can accept the solution or vote the solution .

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900