hello,
i have this result set from query check name column
some column values are forward some are backup i want to show the same formating in gridview when it as sql give out put
its give output as formatted when i bind it with gridview it does not retain formatting
WITH DirectReports (ID, PARENT_NAMEID,HLevel,NAME,Displayname, catnames, ctype, atype, acode, isedit, cguid)
AS
(
-- Anchor member definition
SELECT cm.chart_id,
cd.parent_chart_id,
0 as HLevel,
cast(cm.chart_name as varchar(max)) as NAME,
cast(Right(10000 + (cast('0' as varchar(max)) + cast(cm.chart_id as varchar(max))),4) as varchar(max)) as Displayname ,
cast(cm.chart_name as varchar(max)) as catnames,
cd.charttype,
cd.accounttype,
cd.code,
cd.iseditable,
cd.chartguid
FROM chart_master cm
INNER JOIN chart_master cd ON cm.chart_id = cd.chart_id
WHERE cm.parent_chart_id =0 and cm.IsPublished=1
UNION ALL
-- Recursive member definition
SELECT cm.chart_id,
cd.parent_chart_id,
HLevel+1,
cast((RIGHT(' ',(HLEVEL + 1) * 4) + isnull(cm.chart_name,'')) as varchar(max)) as NAME,
cast(cast(Displayname as varchar(max)) + cast(cm.chart_id as varchar(max)) as varchar(max)) as Displayname ,
cast(cast(catnames as varchar(max)) + ' ----------> '+ cast(cm.chart_name as varchar(max)) as varchar(max)) as catnames ,
cd.charttype,
cd.accounttype,
cd.code,
cd.iseditable,
cd.chartguid
FROM chart_master cm
INNER JOIN chart_master cd on cm.chart_id = cd.chart_id
INNER JOIN DirectReports d on cd.parent_chart_id = d.ID
)
-- Statement that executes the CTE
SELECT ID, PARENT_NAMEID,HLevel,[NAME],Displayname,catnames, ctype, atype,acode ,isedit, cguid ,
(select chart_id from [dbo].[f_topcat] (ID)
) as parentid
from DirectReports