在单列中绑定数据库中的多个值 [英] Bind Multiple value from database in single column

查看:71
本文介绍了在单列中绑定数据库中的多个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望gridview中的数据如下:



CategoryName子类别名称

------------ --------------------

Abc Abc1,abc2,abc3

Bcs Bcs1,bcs2

def Null / No Record



我该怎么做?



我还好吗使用单个表从数据库中获取数据。我有一个表类别,其中我有类似Categryid,parentid,名称的字段。当parentid为0时,它的其他所有其他属于subCategories。



我使用带有c#的asp.net,我想在gridview中使用boundfield 。对于我已经完成的类别,但对于子类别,我不知道该怎么做。



子类别是由它的parentid识别。在子类别中parentid = categryid

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

推荐答案

您必须使用公用表表达式。

有关详细信息,请参阅链接。

http:// blog .sqlauthority.com / 2008/07/28 / sql-server-simple-example-of-recursive-cte / [ ^ ]
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/[^]


这篇关于在单列中绑定数据库中的多个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆