This is a migrated thread and some comments may be shown as answers.

Treelist - getting error

5 Answers 54 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Priya
Top achievements
Rank 1
Priya asked on 10 Jan 2013, 04:19 PM
Hi,
 
I am using TreeList with 2 groupings (and more than 15000 records), everything works fine but sometimes I get yellow screen error while loading records. Please help because I am not able to rectify any reason and moreover  I dont have any null values in database.
Below are the errors which I get :

Server Error in '/' Application.
--------------------------------------------------------------------------------

Value cannot be null.
Parameter name: source
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: source

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

Stack Trace:

[ArgumentNullException: Value cannot be null.
Parameter name: source]
   System.Linq.Enumerable.Where(IEnumerable`1 source, Func`2 predicate) +2719903
   Telerik.Web.UI.RadTreeList.CalculateAggregates(TreeListColumnsCollection Columns) +128
   Telerik.Web.UI.RadTreeList.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) +1910
   System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +66
   Telerik.Web.UI.RadTreeList.PerformDataBinding(IEnumerable data) +2683
   System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +128
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +33
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +143
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +74
   Telerik.Web.UI.RadTreeList.DataBind() +17
   System.Web.UI.Control.DataBindChildren() +201
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +101
   System.Web.UI.Control.DataBind() +15
   System.Web.UI.Control.DataBindChildren() +201
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +101
   System.Web.UI.Control.DataBind() +15
   System.Web.UI.Control.DataBindChildren() +201
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +101
   System.Web.UI.Control.DataBind() +15
   CorpFGBillingThree.afg_invoice_views_list_Telerik.Page_Load(Object sender, EventArgs e) +1756
   System.Web.UI.Control.OnLoad(EventArgs e) +91
   System.Web.UI.Control.LoadRecursive() +74
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207

 

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

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:
System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.



Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
  Telerik.Web.UI.RadTreeList.<CalculateAggregates>b__17(KeyValuePair`2 a) +4
  System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +2060786
  System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +406
  System.Linq.Enumerable.ToList(IEnumerable`1 source) +58
  Telerik.Web.UI.RadTreeList.CalculateAggregates(TreeListColumnsCollection Columns) +217
  Telerik.Web.UI.RadTreeList.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) +1910
  System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +66
  Telerik.Web.UI.RadTreeList.PerformDataBinding(IEnumerable data) +2683
  System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +128
  System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +33
  System.Web.UI.WebControls.DataBoundControl.PerformSelect() +143
  System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +74
  Telerik.Web.UI.RadTreeList.DataBind() +17
  System.Web.UI.Control.DataBindChildren() +201
  System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +101
  System.Web.UI.Control.DataBind() +15
  System.Web.UI.Control.DataBindChildren() +201
  System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +101
  System.Web.UI.Control.DataBind() +15
  System.Web.UI.Control.DataBindChildren() +201
  System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +101
  System.Web.UI.Control.DataBind() +15
  CorpFGBillingThree.afg_invoice_views_list_Telerik.Page_Load(Object sender, EventArgs e) +1756
  System.Web.UI.Control.OnLoad(EventArgs e) +91
  System.Web.UI.Control.LoadRecursive() +74
  System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207

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

Server Error in '/' Application.


Collection was modified; enumeration operation may not execute.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:
System.InvalidOperationException: Collection was modified; enumeration operation may not execute.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.



Stack Trace:


[InvalidOperationException: Collection was modified; enumeration operation may not execute.]
  System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) +52
  System.Collections.Generic.Enumerator.MoveNext() +9592677
  System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +198
  System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +406
  System.Linq.Enumerable.ToList(IEnumerable`1 source) +58
  Telerik.Web.UI.RadTreeList.CalculateAggregates(TreeListColumnsCollection Columns) +217
  Telerik.Web.UI.RadTreeList.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) +1910
  System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +66
  Telerik.Web.UI.RadTreeList.PerformDataBinding(IEnumerable data) +2683
  System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +128
  System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +33
  System.Web.UI.WebControls.DataBoundControl.PerformSelect() +143
  System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +74
  Telerik.Web.UI.RadTreeList.DataBind() +17
  System.Web.UI.Control.DataBindChildren() +201
  System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +101
  System.Web.UI.Control.DataBind() +15
  System.Web.UI.Control.DataBindChildren() +201
  System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +101
  System.Web.UI.Control.DataBind() +15
  System.Web.UI.Control.DataBindChildren() +201
  System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +101
  System.Web.UI.Control.DataBind() +15
  CorpFGBillingThree.afg_invoice_views_list_Telerik.Page_Load(Object sender, EventArgs e) +1756
  System.Web.UI.Control.OnLoad(EventArgs e) +91
  System.Web.UI.Control.LoadRecursive() +74
  System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207

 
 
 

 

5 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 15 Jan 2013, 04:44 PM
Hi,

Based on the provided information it is hard to determine what is the reason for the pointed errors. Can you provide the problematic aspx code and the related code behind, so we can test it locally? 

All the best,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Priya
Top achievements
Rank 1
answered on 16 Jan 2013, 07:18 AM

Hi Pavlina,
I am fetching data based on Group Id  and binding (bound and template ) columns programatically for eg:

 If strGrpId = "5" Then
                            strQry = strQry & " select distinct 'UID' + outer_grp as UID,NULL as PID ,outer_grp as GrpName, outer_grp as inv_id,NULL as Date , NULL as inv_created_date ,NULL as Invoice#,NULL as Branch#,NULL as [Company Contact],Null as Regarding ,NULL as 'By Regarding (Last Name)',NULL as 'By Regarding (First Name)', "
                            strQry = strQry & " NULL as [Billing Contact],NULL as [Company],(outer_grp) as invoice,NULL as aty_finance_yn_1,NULL as aty_finance_yn_2, NULL as [GP Customer Id],NULL as [GP Address Id],NULL as [GP Class Id],"
                            strQry = strQry & " 0 as 'Legal Fees',0 as Expenses, 0 as Discount,0 as '% of Legal Fees',cast(0 as numeric(19,2))  as Total from tbl_afg_temp_invoice_views V "
                            strQry = strQry & "  where org_id=@strOrgId and trans_id=@strTransId   " & strFilterValue & " "
                            If strFrmDate <> "" And strToDate <> "" Then
                                strQry &= " and cast([Date] as DATE) BETWEEN  cast('" & strFrmDate & "' as DATE) and cast('" & strToDate & "' as DATE) "
                            End If
                            strQry = strQry & "  union"

                            strQry = strQry & " (select distinct first_inner_grp + '?' + outer_grp as UID,'UID' + outer_grp as PID , E.epr_petnr_nm as GrpName,first_inner_grp as inv_id,"
                            strQry = strQry & " NULL as Date , NULL as inv_created_date ,NULL as Invoice#,NULL as Branch#, NULL as [Company Contact], Null as Regarding,NULL as 'By Regarding (Last Name)',NULL as 'By Regarding (First Name)', NULL as [Billing Contact],NULL as [Company],(outer_grp+'||'+first_inner_grp) as invoice,NULL as aty_finance_yn_1,NULL as "
                            strQry = strQry & " aty_finance_yn_2, NULL as [GP Customer Id],NULL as [GP Address Id],NULL as [GP Class Id], 0 as 'Legal Fees',0 as Expenses, 0 as Discount,0 as '% of Legal Fees',0 as "
                            strQry = strQry & " Total from tbl_afg_temp_invoice_views  V  join tbl_epr E on V.org_id=E.org_id "
                            strQry = strQry & " and V.first_inner_grp=E.epr_id  where V.org_id=@strOrgId and trans_id=@strTransId  " & strFilterValue & "  and substring(v.first_inner_grp,1,1) like 'P'"
                            If strFrmDate <> "" And strToDate <> "" Then
                                strQry &= " and cast([Date] as DATE) BETWEEN   cast('" & strFrmDate & "' as DATE) and cast('" & strToDate & "' as DATE) "
                            End If
                            strQry &= ") "
                            strQry = strQry & "  union"

                            strQry = strQry & " (select cast(NEWID() as "
                            strQry = strQry & " varchar(100)) as UID,first_inner_grp + '?' + outer_grp as PID,'' as GrpName ,inv_id ,cast(Date as DATE) as Date , cast(inv_created_date as DATE) as  inv_created_date ,Invoice#,Branch#, epr_n_contact as "
                            strQry = strQry & " [Company Contact], bnf_name as Regarding,  isNull(bnf_lname,'') as 'By Regarding (Last Name)',isNull(bnf_fname,'') as 'By Regarding (First Name)', bill_contact_nm as [Billing Contact],epr_petnr_nm as [Company],(outer_grp+'||'+first_inner_grp+'||'+'?'+'||'+inv_id) as invoice,aty_finance_yn_1,aty_finance_yn_2, GP_CustId as [GP Customer Id],"
                            strQry = strQry & " GP_AddId as [GP Address Id],GP_ClassId as [GP Class Id], cast(ISNULL(legal_fees,0) as numeric(19,2)) as 'Legal Fees',cast(ISNULL(Expenses,0) as numeric(19,2)) as Expenses,"
                            strQry = strQry & "  cast(ISNULL(Discount,0) as numeric(19,2)) as Discount,cast(ISNULL(per_of_legal_fees,0) as numeric(19,2))   as '% of Legal Fees',cast(ISNULL(Total,0) as numeric(19,2)) as"
                            strQry = strQry & "  Total   from tbl_afg_temp_invoice_views V where org_id=@strOrgId and trans_id=@strTransId  " & strFilterValue & ""
                            If strFrmDate <> "" And strToDate <> "" Then
                                strQry &= " and cast([Date] as DATE) BETWEEN  cast('" & strFrmDate & "' as DATE) and cast('" & strToDate & "' as DATE) "
                            End If
                            strQry &= ") "
                            strQry = strQry & "  order by GrpName asc , date desc, inv_created_date desc"
                        ElseIf strGrpId = "7" Then
                            strQry = strQry & " select distinct  'UID' + outer_grp as UID,NULL as PID ,outer_grp as GrpName,cast(outer_grp as Date) as seqn, outer_grp as inv_id,NULL as Date , NULL as inv_created_date ,NULL as Invoice#,NULL as Branch#,NULL as [Company Contact],Null as Regarding ,NULL as 'By Regarding (Last Name)',NULL as 'By Regarding (First Name)', "
                            strQry = strQry & " NULL as [Billing Contact],NULL as [Company],(outer_grp) as invoice,NULL as aty_finance_yn_1,NULL as aty_finance_yn_2, NULL as [GP Customer Id],NULL as [GP Address Id],NULL as [GP Class Id],"
                            strQry = strQry & " 0 as 'Legal Fees',0 as Expenses, 0 as Discount,0 as '% of Legal Fees',cast(0 as numeric(19,2))  as Total from tbl_afg_temp_invoice_views V "
                            strQry = strQry & "  where org_id=@strOrgId and trans_id=@strTransId   " & strFilterValue & " "
                            If strFrmDate <> "" And strToDate <> "" Then
                                strQry &= " and cast([Date] as DATE) BETWEEN  cast('" & strFrmDate & "' as DATE) and cast('" & strToDate & "' as DATE) "
                            End If
                            strQry = strQry & "  union"

                            strQry = strQry & " (select distinct first_inner_grp + '?' + outer_grp as UID,'UID' + outer_grp as PID , first_inner_grp as GrpName,'' as seqn,first_inner_grp as inv_id,"
                            strQry = strQry & " NULL as Date , NULL as inv_created_date ,NULL as Invoice#,NULL as Branch#, NULL as [Company Contact], Null as Regarding,NULL as 'By Regarding (Last Name)',NULL as 'By Regarding (First Name)', NULL as [Billing Contact],NULL as [Company],(outer_grp+'||'+first_inner_grp) as invoice,NULL as aty_finance_yn_1,NULL as "
                            strQry = strQry & " aty_finance_yn_2, NULL as [GP Customer Id],NULL as [GP Address Id],NULL as [GP Class Id], 0 as 'Legal Fees',0 as Expenses, 0 as Discount,0 as '% of Legal Fees',0 as "
                            strQry = strQry & " Total from tbl_afg_temp_invoice_views V "
                            strQry = strQry & "  where org_id=@strOrgId and trans_id=@strTransId  " & strFilterValue & ""
                            If strFrmDate <> "" And strToDate <> "" Then
                                strQry &= " and cast([Date] as DATE) BETWEEN   cast('" & strFrmDate & "' as DATE) and cast('" & strToDate & "' as DATE) "
                            End If
                            strQry &= ") "

                            strQry = strQry & " union"
                            strQry = strQry & " (select cast(NEWID() as "
                            strQry = strQry & " varchar(100)) as UID,first_inner_grp + '?' + outer_grp as PID ,'' as GrpName,'' as seqn,inv_id, cast(Date as DATE) as Date , cast(inv_created_date as DATE) as  inv_created_date ,Invoice#,Branch#, epr_n_contact as "
                            strQry = strQry & " [Company Contact], bnf_name as Regarding,  isNull(bnf_lname,'') as 'By Regarding (Last Name)',isNull(bnf_fname,'') as 'By Regarding (First Name)', bill_contact_nm as [Billing Contact],epr_petnr_nm as [Company],(outer_grp+'||'+first_inner_grp+'||'+'?'+'||'+inv_id) as invoice,aty_finance_yn_1,aty_finance_yn_2, GP_CustId as [GP Customer Id],"
                            strQry = strQry & " GP_AddId as [GP Address Id],GP_ClassId as [GP Class Id], cast(ISNULL(legal_fees,0) as numeric(19,2)) as 'Legal Fees',cast(ISNULL(Expenses,0) as numeric(19,2)) as Expenses,"
                            strQry = strQry & "  cast(ISNULL(Discount,0) as numeric(19,2)) as Discount,cast(ISNULL(per_of_legal_fees,0) as numeric(19,2))   as '% of Legal Fees',cast(ISNULL(Total,0) as numeric(19,2)) as"
                            strQry = strQry & "  Total   from tbl_afg_temp_invoice_views V where org_id=@strOrgId and trans_id=@strTransId  " & strFilterValue & ""
                            If strFrmDate <> "" And strToDate <> "" Then
                                strQry &= " and cast([Date] as DATE) BETWEEN   cast('" & strFrmDate & "' as DATE) and cast('" & strToDate & "' as DATE) "
                            End If
                            strQry &= ") "
                            strQry = strQry & "  order by  seqn desc,GrpName asc, date desc, Invoice# asc"
                        ElseIf strGrpId = "12" Then

                            strQry = "  (select distinct  'UID' + outer_grp as UID,NULL as PID ,E.epr_petnr_nm as GrpName, '' as seqn, outer_grp as inv_id,NULL as Date , NULL as inv_created_date ,NULL as Invoice#, NULL as Branch#,NULL as [Company Contact], Null as Regarding,NULL as 'By Regarding (Last Name)',NULL as 'By Regarding (First Name)', "
                            strQry = strQry & " NULL as [Billing Contact],NULL as [Company],(outer_grp) as invoice,NULL as aty_finance_yn_1,NULL as aty_finance_yn_2, NULL as [GP Customer Id],NULL as [GP Address Id],NULL as [GP Class Id],"
                            strQry = strQry & "  0 as 'Legal Fees',0 as Expenses, 0 as Discount,0 as '% of Legal Fees',cast(0 as numeric(19,2)) as Total from tbl_afg_temp_invoice_views V  join tbl_epr E on V.org_id=E.org_id "
                            strQry = strQry & " and V.outer_grp=E.epr_id where V.org_id=@strOrgId and trans_id=@strTransId   " & strFilterValue & "  and substring(v.outer_grp,1,1) like 'P'"
                            If strFrmDate <> "" And strToDate <> "" Then
                                strQry &= " and cast([Date] as DATE) BETWEEN  cast('" & strFrmDate & "' as DATE) and cast('" & strToDate & "' as DATE) "
                            End If
                            strQry &= ") "
                            strQry = strQry & " union"
                            strQry = strQry & " (select distinct first_inner_grp + '?' + outer_grp as UID,'UID' + outer_grp as PID ,first_inner_grp as GrpName, cast(first_inner_grp as Date) as seqn,first_inner_grp as inv_id,"
                            strQry = strQry & " NULL as Date , NULL as inv_created_date ,NULL as Invoice#,NULL as Branch#, NULL as [Company Contact],Null as Regarding, NULL as 'By Regarding (Last Name)',NULL as 'By Regarding (First Name)', NULL as [Billing Contact],NULL as [Company],(outer_grp+'||'+first_inner_grp) as invoice,NULL as aty_finance_yn_1,NULL as "
                            strQry = strQry & " aty_finance_yn_2, NULL as [GP Customer Id],NULL as [GP Address Id],NULL as [GP Class Id], 0 as 'Legal Fees',0 as Expenses, 0 as Discount,0 as '% of Legal Fees',0 as "
                            strQry = strQry & " Total from tbl_afg_temp_invoice_views V  where org_id=@strOrgId and trans_id=@strTransId  " & strFilterValue & " "
                            If strFrmDate <> "" And strToDate <> "" Then
                                strQry &= " and cast([Date] as DATE) BETWEEN  cast('" & strFrmDate & "' as DATE) and cast('" & strToDate & "' as DATE) "
                            End If
                            strQry &= ") "
                            strQry = strQry & "  union"
                            strQry = strQry & " (select cast(NEWID() as "
                            strQry = strQry & " varchar(100)) as UID,first_inner_grp + '?' + outer_grp as PID ,'' as GrpName, '' as seqn,inv_id,cast(Date as DATE) as Date , cast(inv_created_date as DATE) as  inv_created_date ,Invoice#,Branch#, epr_n_contact as "
                            strQry = strQry & " [Company Contact], bnf_name as Regarding,  isNull(bnf_lname,'') as 'By Regarding (Last Name)',isNull(bnf_fname,'') as 'By Regarding (First Name)', bill_contact_nm as [Billing Contact],epr_petnr_nm as [Company],(outer_grp+'||'+first_inner_grp+'||'+'?'+'||'+inv_id) as invoice,aty_finance_yn_1,aty_finance_yn_2, GP_CustId as [GP Customer Id],"
                            strQry = strQry & " GP_AddId as [GP Address Id],GP_ClassId as [GP Class Id], cast(ISNULL(legal_fees,0) as numeric(19,2)) as 'Legal Fees',cast(ISNULL(Expenses,0) as numeric(19,2)) as Expenses,"
                            strQry = strQry & "  cast(ISNULL(Discount,0) as numeric(19,2)) as Discount,cast(ISNULL(per_of_legal_fees,0) as numeric(19,2))   as '% of Legal Fees',cast(ISNULL(Total,0) as numeric(19,2)) as"
                            strQry = strQry & "  Total   from tbl_afg_temp_invoice_views V where org_id=@strOrgId and trans_id=@strTransId  " & strFilterValue & " "
                            If strFrmDate <> "" And strToDate <> "" Then
                                strQry &= " and cast([Date] as DATE) BETWEEN  cast('" & strFrmDate & "' as DATE) and cast('" & strToDate & "' as DATE) "
                            End If
                            strQry &= ") "
                            strQry = strQry & "  order by seqn desc, GrpName asc , date desc, Invoice# asc"
                        ElseIf strGrpId = "25" Then
                            strQry = strQry & " select distinct  'UID' + outer_grp as UID,NULL as PID ,outer_grp as GrpName, '' as seqn,outer_grp as inv_id,NULL as Date , NULL as inv_created_date ,NULL as Invoice#,NULL as Branch#,NULL as [Company Contact],Null as Regarding ,NULL as 'By Regarding (Last Name)',NULL as 'By Regarding (First Name)', "
                            strQry = strQry & " NULL as [Billing Contact],NULL as [Company],(outer_grp) as invoice,NULL as aty_finance_yn_1,NULL as aty_finance_yn_2, NULL as [GP Customer Id],NULL as [GP Address Id],NULL as [GP Class Id],"
                            strQry = strQry & " 0 as 'Legal Fees',0 as Expenses, 0 as Discount,0 as '% of Legal Fees',cast(0 as numeric(19,2))  as Total from tbl_afg_temp_invoice_views V "
                            strQry = strQry & "  where org_id=@strOrgId and trans_id=@strTransId  " & strFilterValue & "  "
                            If strFrmDate <> "" And strToDate <> "" Then
                                strQry &= " and cast([Date] as DATE) BETWEEN  cast('" & strFrmDate & "' as DATE) and cast('" & strToDate & "' as DATE) "
                            End If
                            strQry = strQry & "  union"

                            strQry = strQry & " (select distinct first_inner_grp + '?' + outer_grp as UID,'UID' + outer_grp as PID , first_inner_grp as GrpName,cast(first_inner_grp as Date) as seqn ,first_inner_grp as inv_id,"
                            strQry = strQry & " NULL as Date , NULL as inv_created_date ,NULL as Invoice#,NULL as Branch#, NULL as [Company Contact], Null as Regarding,NULL as 'By Regarding (Last Name)',NULL as 'By Regarding (First Name)', NULL as [Billing Contact],NULL as [Company],(outer_grp+'||'+first_inner_grp) as invoice,NULL as aty_finance_yn_1,NULL as "
                            strQry = strQry & " aty_finance_yn_2, NULL as [GP Customer Id],NULL as [GP Address Id],NULL as [GP Class Id], 0 as 'Legal Fees',0 as Expenses, 0 as Discount,0 as '% of Legal Fees',0 as "
                            strQry = strQry & " Total from tbl_afg_temp_invoice_views V where org_id=@strOrgId and trans_id=@strTransId  " & strFilterValue & ""
                            If strFrmDate <> "" And strToDate <> "" Then
                                strQry &= " and cast([Date] as DATE) BETWEEN  cast('" & strFrmDate & "' as DATE) and cast('" & strToDate & "' as DATE) "
                            End If
                            strQry &= ") "

                            strQry = strQry & " union"
                            strQry = strQry & " (select cast(NEWID() as "
                            strQry = strQry & " varchar(100)) as UID,first_inner_grp + '?' + outer_grp as PID ,'' as GrpName,'' as seqn,inv_id,cast(Date as DATE) as Date , cast(inv_created_date as DATE) as  inv_created_date ,Invoice#,Branch#, epr_n_contact as "
                            strQry = strQry & " [Company Contact], bnf_name as Regarding,  isNull(bnf_lname,'') as 'By Regarding (Last Name)',isNull(bnf_fname,'') as 'By Regarding (First Name)', bill_contact_nm as [Billing Contact],epr_petnr_nm as [Company],(outer_grp+'||'+first_inner_grp+'||'+'?'+'||'+inv_id) as invoice,aty_finance_yn_1,aty_finance_yn_2, GP_CustId as [GP Customer Id],"
                            strQry = strQry & " GP_AddId as [GP Address Id],GP_ClassId as [GP Class Id], cast(ISNULL(legal_fees,0) as numeric(19,2)) as 'Legal Fees',cast(ISNULL(Expenses,0) as numeric(19,2)) as Expenses,"
                            strQry = strQry & "  cast(ISNULL(Discount,0) as numeric(19,2)) as Discount,cast(ISNULL(per_of_legal_fees,0) as numeric(19,2))   as '% of Legal Fees',cast(ISNULL(Total,0) as numeric(19,2)) as"
                            strQry = strQry & "  Total   from tbl_afg_temp_invoice_views V where org_id=@strOrgId and trans_id=@strTransId  " & strFilterValue & ""
                            If strFrmDate <> "" And strToDate <> "" Then
                                strQry &= " and cast([Date] as DATE) BETWEEN  cast('" & strFrmDate & "' as DATE) and cast('" & strToDate & "' as DATE) "
                            End If
                            strQry &= ") "
                            strQry = strQry & "  order by seqn desc,GrpName asc , date desc, Invoice# asc"
                        ElseIf strGrpId = "2" Or strGrpId = "22" Or strGrpId = "21" Or strGrpId = "30" Then
                            'strQry = "  (select distinct  outer_grp as UID,NULL as PID,outer_grp as grp_name,E.epr_petnr_nm as GrpName, outer_grp as inv_id,NULL as Date,NULL as Invoice#, NULL as Branch#,NULL as [Company Contact], Null as Regarding,NULL as 'By Regarding Last Name',NULL as 'By Regarding First Name', "
                            'strQry = strQry & " NULL as [Billing Contact],NULL as [Company],NULL as invoice,NULL as aty_finance_yn_1,NULL as aty_finance_yn_2, NULL as [GP Customer Id],NULL as [GP Address Id],NULL as [GP Class Id],"
                            'strQry = strQry & "  0 as 'Legal Fees',0 as Expenses, 0 as Discount,0 as '% of Legal Fees',cast(0 as numeric(19,2)) as Total from tbl_afg_temp_invoice_views V  join tbl_epr E on V.org_id=E.org_id "
                            'strQry = strQry & " and V.outer_grp=E.epr_id where V.org_id=@strOrgId and trans_id=@strTransId   and substring(v.outer_grp,1,1) like 'P'"
                            'strQry = strQry & " union"
                            strQry = " ((select distinct  'UID' + outer_grp as UID,NULL as PID ,isNull(B.bnf_lname,'')+ ' '+isNull(B.bnf_fname,'') as GrpName, outer_grp as inv_id,NULL as Date , NULL as inv_created_date ,NULL as Invoice#,NULL as Branch#,NULL as [Company Contact],Null as Regarding,NULL as 'By Regarding Last Name',NULL as 'By Regarding First Name', "
                            strQry = strQry & " NULL as [Billing Contact],NULL as [Company],(outer_grp) as invoice,NULL as aty_finance_yn_1,NULL as aty_finance_yn_2, NULL as [GP Customer Id],NULL as [GP Address Id],NULL as [GP Class Id],"
                            strQry = strQry & " 0 as 'Legal Fees',0 as Expenses, 0 as Discount,0 as '% of Legal Fees',cast(0 as numeric(19,2)) as Total from tbl_afg_temp_invoice_views V join tbl_bnf B on V.org_id=B.org_id and"
                            strQry = strQry & " V.outer_grp=B.bnf_id where V.org_id=@strOrgId and trans_id=@strTransId   " & strFilterValue & "  and substring(V.outer_grp,1,1) like 'B' "
                            If strFrmDate <> "" And strToDate <> "" Then
                                strQry &= " and cast([Date] as DATE) BETWEEN  cast('" & strFrmDate & "' as DATE) and cast('" & strToDate & "' as DATE) "
                            End If
                            'strQry &= ") "
                            strQry = strQry & ") "
                            strQry = strQry & " union (select distinct  'UID' + outer_grp as UID,NULL as PID ,E.epr_petnr_nm as GrpName, outer_grp as inv_id,NULL as Date , NULL as inv_created_date ,NULL as Invoice#,NULL as Branch#,NULL as [Company Contact],Null as Regarding,NULL as 'By Regarding Last Name',NULL as 'By Regarding First Name', "
                            strQry = strQry & " NULL as [Billing Contact],NULL as [Company],(outer_grp) as invoice,NULL as aty_finance_yn_1,NULL as aty_finance_yn_2, NULL as [GP Customer Id],NULL as [GP Address Id],NULL as [GP Class Id],"
                            strQry = strQry & " 0 as 'Legal Fees',0 as Expenses, 0 as Discount,0 as '% of Legal Fees',cast(0 as numeric(19,2)) as Total from tbl_afg_temp_invoice_views V inner join tbl_epr E on V.org_id=E.org_id and"
                            strQry = strQry & " V.outer_grp=E.epr_id where V.org_id=@strOrgId  and trans_id=@strTransId  " & strFilterValue & "  and substring(V.outer_grp,1,1) like 'P'"
                            If strFrmDate <> "" And strToDate <> "" Then
                                strQry &= " and cast([Date] as DATE) BETWEEN  cast('" & strFrmDate & "' as DATE) and cast('" & strToDate & "' as DATE) "
                            End If
                            strQry &= ") "
                            strQry = strQry & ") "
                            strQry = strQry & "  union"

                            strQry = strQry & " (select distinct first_inner_grp + '?' + outer_grp as UID,'UID' + outer_grp as PID , E.epr_petnr_nm as GrpName,first_inner_grp as inv_id,"
                            strQry = strQry & " NULL as Date , NULL as inv_created_date ,NULL as Invoice#,NULL as Branch#, NULL as [Company Contact], Null as Regarding,NULL as 'By Regarding Last Name',NULL as 'By Regarding First Name', NULL as [Billing Contact],NULL as [Company],(outer_grp+'||'+first_inner_grp) as invoice,NULL as aty_finance_yn_1,NULL as "
                            strQry = strQry & " aty_finance_yn_2, NULL as [GP Customer Id],NULL as [GP Address Id],NULL as [GP Class Id], 0 as 'Legal Fees',0 as Expenses, 0 as Discount,0 as '% of Legal Fees', "
                            strQry = strQry & " cast(0 as numeric(19,2)) as Total from tbl_afg_temp_invoice_views  V  join tbl_epr E on V.org_id=E.org_id "
                            strQry = strQry & " and V.first_inner_grp=E.epr_id  where V.org_id=@strOrgId and trans_id=@strTransId  " & strFilterValue & " and substring(v.first_inner_grp,1,1) like 'P' "
                            If strFrmDate <> "" And strToDate <> "" Then
                                strQry &= " and cast([Date] as DATE) BETWEEN  cast('" & strFrmDate & "' as DATE) and cast('" & strToDate & "' as DATE) "
                            End If
                            strQry &= ") "
                            strQry = strQry & "  union"
                            strQry = strQry & " (select cast(NEWID() as "
                            strQry = strQry & " varchar(100)) as UID,first_inner_grp + '?' + outer_grp as PID ,'' as GrpName,inv_id, cast(Date as DATE) as Date , cast(inv_created_date as DATE) as  inv_created_date ,Invoice#,Branch#, epr_n_contact as "
                            strQry = strQry & " [Company Contact], bnf_name as Regarding,  isNull(bnf_lname,'') as 'By Regarding Last Name',isNull(bnf_fname,'') as 'By Regarding First Name', bill_contact_nm as [Billing Contact],epr_petnr_nm as [Company],(outer_grp+'||'+first_inner_grp+'||'+'?'+'||'+inv_id) as invoice,aty_finance_yn_1,aty_finance_yn_2, GP_CustId as [GP Customer Id],"
                            strQry = strQry & " GP_AddId as [GP Address Id],GP_ClassId as [GP Class Id], cast(ISNULL(legal_fees,0) as numeric(19,2)) as 'Legal Fees',cast(ISNULL(Expenses,0) as numeric(19,2)) as Expenses,"
                            strQry = strQry & "  cast(ISNULL(Discount,0) as numeric(19,2)) as Discount,cast(ISNULL(per_of_legal_fees,0) as numeric(19,2))   as '% of Legal Fees',cast(ISNULL(Total,0) as numeric(19,2)) as"
                            strQry = strQry & "  Total   from tbl_afg_temp_invoice_views V where org_id=@strOrgId and trans_id=@strTransId  " & strFilterValue & ""
                            If strFrmDate <> "" And strToDate <> "" Then
                                strQry &= " and cast([Date] as DATE) BETWEEN  cast('" & strFrmDate & "' as DATE) and cast('" & strToDate & "' as DATE) "
                            End If
                            strQry &= ") "
                            strQry = strQry & "  order by GrpName asc , Date desc, Invoice# asc, inv_created_date desc"

End If

                    objdb.addParameter("@strOrgId", SqlDbType.VarChar, 25, m_strOrgId, INSZoom.Library.DB.sql.Validator.Yes)
                    objdb.addParameter("@strTransId", SqlDbType.VarChar, 25, strTransId, INSZoom.Library.DB.sql.Validator.Yes)
                    reader = objdb.ReturnDataReader(strQry, INSZoom.Library.DB.sql.sqlType.text)

                    RadTreeList1.AutoGenerateColumns = False
                    RadTreeList1.Columns.Clear()

  Dim templateColumn As New TreeListTemplateColumn 'Template Column for creating CheckBox

                    templateColumn = New TreeListTemplateColumn()
                    templateColumn.HeaderText = "&nbsp;"
                    templateColumn.HeaderStyle.Width = "30"
                    templateColumn.HeaderStyle.HorizontalAlign = 1
                    templateColumn.DataField = "invoice"
                    templateColumn.UniqueName = "ChkFirstInnnerNode"
                    templateColumn.ItemStyle.Width = "30"
                    templateColumn.Resizable = False
                    templateColumn.ItemStyle.HorizontalAlign = 1
                    templateColumn.ItemTemplate = New ChkFirstInnerColumn(templateColumn.DataField)
                    RadTreeList1.Columns.Add(templateColumn)

                    boundColumn = New TreeListBoundColumn()           'Creating other Columns
                    boundColumn.DataField = "GrpName"
                    boundColumn.UniqueName = "GrpName"
                    boundColumn.HeaderText = "&nbsp;"
                    RadTreeList1.Columns.Add(boundColumn)

                    boundColumn = New TreeListBoundColumn()

     Select Case strGrpId
                        Case "26"
                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "inv_responsibility"
                            boundColumn.UniqueName = "inv_responsibility"
                            boundColumn.HeaderText = "Invoice Responsibility"
                            boundColumn.HeaderStyle.Width = "90"
                            boundColumn.ItemStyle.Width = "90"
                            RadTreeList1.Columns.Add(boundColumn)

 

                            templateColumn = New TreeListTemplateColumn()
                            templateColumn.HeaderText = "Invoice #"
                            templateColumn.HeaderStyle.Width = "90"
                            templateColumn.DataField = "Invoice#"
                            templateColumn.ItemStyle.Width = "90"
                            templateColumn.UniqueName = "inv_id"
                            templateColumn.ItemTemplate = New InvTemplColumn(templateColumn.DataField, strGrpId)
                            RadTreeList1.Columns.Add(templateColumn)

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Date"
                            boundColumn.UniqueName = "Date"
                            boundColumn.HeaderText = "Date"
                            boundColumn.HeaderStyle.Width = "70"
                            boundColumn.ItemStyle.Width = "70"
                            boundColumn.DataFormatString = "{0:MM/dd/yyyy}"
                            boundColumn.DataType = GetType(Date)
                            RadTreeList1.Columns.Add(boundColumn)

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Branch#"
                            boundColumn.UniqueName = "Branch#"
                            boundColumn.HeaderText = "Branch #"
                            RadTreeList1.Columns.Add(boundColumn)

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Regarding"
                            boundColumn.UniqueName = "Regarding"
                            boundColumn.HeaderText = "Regarding"
                            RadTreeList1.Columns.Add(boundColumn)

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Billing Contact"
                            boundColumn.UniqueName = "Billing Contact"
                            boundColumn.HeaderText = "Billing Contact"
                            RadTreeList1.Columns.Add(boundColumn)
                        Case "12", "13", "23", "28"

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Date"
                            boundColumn.UniqueName = "Date"
                            boundColumn.HeaderText = "Date"
                            boundColumn.DataFormatString = "{0:MM/dd/yyyy}"
                            boundColumn.DataType = GetType(Date)
                            RadTreeList1.Columns.Add(boundColumn)

                            templateColumn = New TreeListTemplateColumn()
                            templateColumn.HeaderText = "Invoice #"
                            templateColumn.HeaderStyle.Width = "90"
                            templateColumn.DataField = "Invoice#"
                            templateColumn.ItemStyle.Width = "90"
                            'templateColumn.Resizable = False
                            templateColumn.UniqueName = "inv_id"
                            templateColumn.ItemTemplate = New InvTemplColumn(templateColumn.DataField, strGrpId)
                            RadTreeList1.Columns.Add(templateColumn)

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Branch#"
                            boundColumn.UniqueName = "Branch#"
                            boundColumn.HeaderText = "Branch #"
                            RadTreeList1.Columns.Add(boundColumn)

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Regarding"
                            boundColumn.UniqueName = "Regarding"
                            boundColumn.HeaderText = "Regarding"
                            RadTreeList1.Columns.Add(boundColumn)

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Billing Contact"
                            boundColumn.UniqueName = "Billing Contact"
                            boundColumn.HeaderText = "Billing Contact"
                            RadTreeList1.Columns.Add(boundColumn)
                        Case "27", "14", "29"

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Date"
                            boundColumn.UniqueName = "Date"
                            boundColumn.HeaderText = "Date"
                            boundColumn.HeaderStyle.Width = "70"
                            boundColumn.ItemStyle.Width = "70"
                            'boundColumn.Resizable = False
                            boundColumn.DataFormatString = "{0:MM/dd/yyyy}"
                            boundColumn.DataType = GetType(Date)
                            RadTreeList1.Columns.Add(boundColumn)

 

                            templateColumn = New TreeListTemplateColumn()
                            templateColumn.HeaderText = "Invoice #"
                            templateColumn.HeaderStyle.Width = "90"
                            templateColumn.DataField = "Invoice#"
                            templateColumn.ItemStyle.Width = "90"
                            'templateColumn.Resizable = False
                            templateColumn.UniqueName = "inv_id"
                            templateColumn.ItemTemplate = New InvTemplColumn(templateColumn.DataField, strGrpId)
                            RadTreeList1.Columns.Add(templateColumn)

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Regarding"
                            boundColumn.UniqueName = "Regarding"
                            boundColumn.HeaderText = "Regarding"
                            RadTreeList1.Columns.Add(boundColumn)

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Branch#"
                            boundColumn.UniqueName = "Branch#"
                            boundColumn.HeaderText = "Branch #"
                            RadTreeList1.Columns.Add(boundColumn)

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Billing Contact"
                            boundColumn.UniqueName = "Billing Contact"
                            boundColumn.HeaderText = "Billing Contact"
                            RadTreeList1.Columns.Add(boundColumn)

                        Case "22", "2", "21", "30"

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "By Regarding Last Name"
                            boundColumn.UniqueName = "By Regarding Last Name"
                            boundColumn.HeaderText = "By Regarding (Last Name)"
                            RadTreeList1.Columns.Add(boundColumn)

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "By Regarding First Name"
                            boundColumn.UniqueName = "By Regarding First Name"
                            boundColumn.HeaderText = "By Regarding (First Name)"
                            RadTreeList1.Columns.Add(boundColumn)

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Date"
                            boundColumn.UniqueName = "Date"
                            boundColumn.HeaderText = "Date"
                            boundColumn.DataFormatString = "{0:MM/dd/yyyy}"
                            boundColumn.HeaderStyle.Width = "70"
                            boundColumn.ItemStyle.Width = "70"
                            'boundColumn.Resizable = False
                            boundColumn.DataType = GetType(Date)
                            RadTreeList1.Columns.Add(boundColumn)

                            templateColumn = New TreeListTemplateColumn()
                            templateColumn.HeaderText = "Invoice #"
                            templateColumn.HeaderStyle.Width = "90"
                            templateColumn.DataField = "Invoice#"
                            templateColumn.ItemStyle.Width = "90"
                            'templateColumn.Resizable = False
                            templateColumn.UniqueName = "inv_id"
                            templateColumn.ItemTemplate = New InvTemplColumn(templateColumn.DataField, strGrpId)
                            RadTreeList1.Columns.Add(templateColumn)

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Billing Contact"
                            boundColumn.UniqueName = "Billing Contact"
                            boundColumn.HeaderText = "Billing Contact"
                            RadTreeList1.Columns.Add(boundColumn)

                        Case "1", "11", "4", "6", "7", "25", "19", "17", "20"

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Date"
                            boundColumn.UniqueName = "Date"
                            boundColumn.HeaderText = "Date"
                            boundColumn.HeaderStyle.Width = "70"
                            boundColumn.ItemStyle.Width = "70"
                            'boundColumn.Resizable = False
                            boundColumn.DataFormatString = "{0:MM/dd/yyyy}"
                            boundColumn.DataType = GetType(Date)
                            RadTreeList1.Columns.Add(boundColumn)

                            templateColumn = New TreeListTemplateColumn()
                            templateColumn.HeaderText = "Invoice #"
                            templateColumn.HeaderStyle.Width = "90"
                            templateColumn.DataField = "Invoice#"
                            templateColumn.ItemStyle.Width = "90"
                            'templateColumn.Resizable = False
                            templateColumn.UniqueName = "inv_id"
                            templateColumn.ItemTemplate = New InvTemplColumn(templateColumn.DataField, strGrpId)
                            RadTreeList1.Columns.Add(templateColumn)

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Company Contact"
                            boundColumn.UniqueName = "Company Contact"
                            boundColumn.HeaderText = "Company (Contact)"
                            RadTreeList1.Columns.Add(boundColumn)

                        Case "3", "18"

                            templateColumn = New TreeListTemplateColumn()
                            templateColumn.HeaderText = "Invoice #"
                            templateColumn.HeaderStyle.Width = "90"
                            templateColumn.DataField = "Invoice#"
                            templateColumn.ItemStyle.Width = "90"
                            'templateColumn.Resizable = False
                            templateColumn.UniqueName = "inv_id"
                            templateColumn.ItemTemplate = New InvTemplColumn(templateColumn.DataField, strGrpId)
                            RadTreeList1.Columns.Add(templateColumn)

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Date"
                            boundColumn.UniqueName = "Date"
                            boundColumn.HeaderText = "Date"
                            boundColumn.HeaderStyle.Width = "70"
                            boundColumn.ItemStyle.Width = "70"
                            'boundColumn.Resizable = False
                            boundColumn.DataFormatString = "{0:MM/dd/yyyy}"
                            boundColumn.DataType = GetType(Date)
                            RadTreeList1.Columns.Add(boundColumn)

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Branch#"
                            boundColumn.UniqueName = "Branch#"
                            boundColumn.HeaderText = "Branch #"
                            RadTreeList1.Columns.Add(boundColumn)

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Regarding"
                            boundColumn.UniqueName = "Regarding"
                            boundColumn.HeaderText = "Regarding"
                            RadTreeList1.Columns.Add(boundColumn)

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Billing Contact"
                            boundColumn.UniqueName = "Billing Contact"
                            boundColumn.HeaderText = "Billing Contact"
                            RadTreeList1.Columns.Add(boundColumn)

                        Case "5"

                            templateColumn = New TreeListTemplateColumn()
                            templateColumn.HeaderText = "Invoice #"
                            templateColumn.HeaderStyle.Width = "90"
                            templateColumn.DataField = "Invoice#"
                            templateColumn.ItemStyle.Width = "90"
                            'templateColumn.Resizable = False
                            templateColumn.UniqueName = "inv_id"
                            templateColumn.ItemTemplate = New InvTemplColumn(templateColumn.DataField, strGrpId)
                            RadTreeList1.Columns.Add(templateColumn)

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Date"
                            boundColumn.UniqueName = "Date"
                            boundColumn.HeaderText = "Date"
                            boundColumn.HeaderStyle.Width = "70"
                            boundColumn.ItemStyle.Width = "70"
                            'boundColumn.Resizable = False
                            boundColumn.DataFormatString = "{0:MM/dd/yyyy}"
                            boundColumn.DataType = GetType(Date)
                            RadTreeList1.Columns.Add(boundColumn)

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Regarding"
                            boundColumn.UniqueName = "Regarding"
                            boundColumn.HeaderText = "Regarding"
                            RadTreeList1.Columns.Add(boundColumn)

                        Case "8"

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Date"
                            boundColumn.UniqueName = "Date"
                            boundColumn.HeaderText = "Date"
                            boundColumn.HeaderStyle.Width = "70"
                            boundColumn.ItemStyle.Width = "70"
                            'boundColumn.Resizable = False
                            boundColumn.DataFormatString = "{0:MM/dd/yyyy}"
                            boundColumn.DataType = GetType(Date)
                            RadTreeList1.Columns.Add(boundColumn)

                            templateColumn = New TreeListTemplateColumn()
                            templateColumn.HeaderText = "Invoice #"
                            templateColumn.HeaderStyle.Width = "90"
                            templateColumn.DataField = "Invoice#"
                            templateColumn.ItemStyle.Width = "90"
                            'templateColumn.Resizable = False
                            templateColumn.UniqueName = "inv_id"
                            templateColumn.ItemTemplate = New InvTemplColumn(templateColumn.DataField, strGrpId)
                            RadTreeList1.Columns.Add(templateColumn)

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Branch#"
                            boundColumn.UniqueName = "Branch#"
                            boundColumn.HeaderText = "Branch #"
                            RadTreeList1.Columns.Add(boundColumn)

                        Case "9"

                            templateColumn = New TreeListTemplateColumn()
                            templateColumn.HeaderText = "Date"
                            templateColumn.DataField = "Date"
                            templateColumn.HeaderStyle.Width = "70"
                            templateColumn.ItemStyle.Width = "70"
                            'templateColumn.Resizable = False
                            templateColumn.UniqueName = "Date"
                            templateColumn.ItemTemplate = New InvTemplColumn(templateColumn.DataField, strGrpId)
                            templateColumn.DataType = GetType(Date)
                            RadTreeList1.Columns.Add(templateColumn)

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Branch#"
                            boundColumn.UniqueName = "Branch#"
                            boundColumn.HeaderText = "Branch #"
                            RadTreeList1.Columns.Add(boundColumn)

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Company Contact"
                            boundColumn.UniqueName = "Company Contact"
                            boundColumn.HeaderText = "Company (Regarding)"
                            RadTreeList1.Columns.Add(boundColumn)

                        Case "10"

                            templateColumn = New TreeListTemplateColumn()
                            templateColumn.HeaderText = "Date"
                            templateColumn.DataField = "Date"
                            templateColumn.HeaderStyle.Width = "70"
                            templateColumn.ItemStyle.Width = "70"
                            templateColumn.UniqueName = "Date"
                            'templateColumn.Resizable = False
                            templateColumn.ItemTemplate = New InvTemplColumn(templateColumn.DataField, strGrpId)
                            templateColumn.DataType = GetType(Date)
                            RadTreeList1.Columns.Add(templateColumn)

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Branch#"
                            boundColumn.UniqueName = "Branch#"
                            boundColumn.HeaderText = "Branch #"
                            RadTreeList1.Columns.Add(boundColumn)

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Company"
                            boundColumn.UniqueName = "Company"
                            boundColumn.HeaderText = "Company"
                            RadTreeList1.Columns.Add(boundColumn)

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Regarding"
                            boundColumn.UniqueName = "Regarding"
                            boundColumn.HeaderText = "Regarding"
                            RadTreeList1.Columns.Add(boundColumn)

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Billing Contact"
                            boundColumn.UniqueName = "Billing Contact"
                            boundColumn.HeaderText = "Billing Contact"
                            RadTreeList1.Columns.Add(boundColumn)

                        Case "16"

                            templateColumn = New TreeListTemplateColumn()
                            templateColumn.HeaderText = "Invoice #"
                            templateColumn.HeaderStyle.Width = "90"
                            templateColumn.DataField = "Invoice#"
                            templateColumn.ItemStyle.Width = "90"
                            'templateColumn.Resizable = False
                            templateColumn.UniqueName = "inv_id"
                            templateColumn.ItemTemplate = New InvTemplColumn(templateColumn.DataField, strGrpId)
                            RadTreeList1.Columns.Add(templateColumn)

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Branch#"
                            boundColumn.UniqueName = "Branch#"
                            boundColumn.HeaderText = "Branch #"
                            RadTreeList1.Columns.Add(boundColumn)

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Date"
                            boundColumn.UniqueName = "Date"
                            boundColumn.HeaderText = "Date"
                            boundColumn.HeaderStyle.Width = "70"
                            boundColumn.ItemStyle.Width = "70"
                            'boundColumn.Resizable = False
                            boundColumn.DataFormatString = "{0:MM/dd/yyyy}"
                            boundColumn.DataType = GetType(Date)
                            RadTreeList1.Columns.Add(boundColumn)

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Company"
                            boundColumn.UniqueName = "Company"
                            boundColumn.HeaderText = "Company"
                            RadTreeList1.Columns.Add(boundColumn)

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Regarding"
                            boundColumn.UniqueName = "Regarding"
                            boundColumn.HeaderText = "Regarding"
                            RadTreeList1.Columns.Add(boundColumn)

                            boundColumn = New TreeListBoundColumn()
                            boundColumn.DataField = "Billing Contact"
                            boundColumn.UniqueName = "Billing Contact"
                            boundColumn.HeaderText = "Billing Contact"
                            RadTreeList1.Columns.Add(boundColumn)

                    End Select

                    '*****************************common***************************************************
                    If strGrpId <> "10" Then

                        boundColumn = New TreeListBoundColumn()
                        boundColumn.DataField = "Legal Fees"
                        boundColumn.UniqueName = "Legal Fees"
                        boundColumn.HeaderText = "Legal Fees"

                        boundColumn.ItemStyle.HorizontalAlign = 3
                        Try

                            boundColumn.Aggregate = TreeListAggregateFunction.Sum
                            boundColumn.DataFormatString = "${0:n}"
                            boundColumn.FooterAggregateFormatString = "${0:n}"
                        Catch ex As Exception

                        End Try

 

                        RadTreeList1.Columns.Add(boundColumn)

                        If strGrpId = "2" Or strGrpId = "22" Or strGrpId = "21" Or strGrpId = "30" Then
                            boundColumn.Visible = False                        'Hiding Column for specific Group Id
                        End If

                        boundColumn = New TreeListBoundColumn()
                        boundColumn.DataField = "Expenses"
                        boundColumn.UniqueName = "Expenses"
                        boundColumn.HeaderText = "Expenses"

                        boundColumn.ItemStyle.HorizontalAlign = 3
                        Try

                            boundColumn.Aggregate = TreeListAggregateFunction.Sum
                            boundColumn.DataFormatString = "${0:n}"
                            boundColumn.FooterAggregateFormatString = "${0:n}"
                        Catch ex As Exception

                        End Try

                        RadTreeList1.Columns.Add(boundColumn)

                        If strGrpId = "2" Or strGrpId = "22" Or strGrpId = "21" Or strGrpId = "30" Then
                            boundColumn.Visible = False                       'Hiding Column for specific Group Id
                        End If

                        boundColumn = New TreeListBoundColumn()
                        boundColumn.DataField = "Discount"
                        boundColumn.UniqueName = "Discount"
                        boundColumn.HeaderText = "Discount"

                        boundColumn.ItemStyle.HorizontalAlign = 3
                        Try

                            boundColumn.Aggregate = TreeListAggregateFunction.Sum
                            boundColumn.DataFormatString = "${0:n}"
                            boundColumn.FooterAggregateFormatString = "${0:n}"
                        Catch ex As Exception

                        End Try
                        RadTreeList1.Columns.Add(boundColumn)

                        If strGrpId = "2" Or strGrpId = "22" Or strGrpId = "21" Or strGrpId = "30" Then
                            boundColumn.Visible = False                     'Hiding Column for specific Group Id
                        End If

                        boundColumn = New TreeListBoundColumn()
                        boundColumn.DataField = "% of Legal Fees"
                        boundColumn.UniqueName = "% of Legal Fees"
                        boundColumn.HeaderText = "% of Legal Fees"

                        boundColumn.ItemStyle.HorizontalAlign = 3
                        Try

                            boundColumn.Aggregate = TreeListAggregateFunction.Sum
                            boundColumn.DataFormatString = "${0:n}"
                            boundColumn.FooterAggregateFormatString = "${0:n}"
                        Catch ex As Exception

                        End Try
                        RadTreeList1.Columns.Add(boundColumn)
                        If strGrpId = "2" Or strGrpId = "22" Or strGrpId = "21" Or strGrpId = "30" Then
                            boundColumn.Visible = False                      'Hiding Column for specific Group Id
                        End If

                        boundColumn = New TreeListBoundColumn()
                        boundColumn.DataField = "Total"
                        boundColumn.UniqueName = "Total"
                        boundColumn.HeaderText = "Total"
                        boundColumn.ItemStyle.HorizontalAlign = 3
                        boundColumn.HeaderStyle.Width = "130"
                        boundColumn.ItemStyle.Width = "130"
                        'boundColumn.MinWidth = "120"
                        'boundColumn.Resizable = False
                        Try

                            boundColumn.Aggregate = TreeListAggregateFunction.Sum
                            boundColumn.DataFormatString = "${0:n}"
                            boundColumn.FooterAggregateFormatString = "${0:n}"
                        Catch ex As Exception

                        End Try
                        RadTreeList1.Columns.Add(boundColumn)

 

                    End If

                    If strGrpId = "5" Or strGrpId = "8" Then

                        boundColumn = New TreeListBoundColumn()
                        boundColumn.DataField = "GP Customer Id"
                        boundColumn.UniqueName = "GP Customer Id"
                        boundColumn.HeaderText = "GP Customer Id"
                        boundColumn.HeaderStyle.Width = "100"
                        boundColumn.ItemStyle.Width = "100"
                        RadTreeList1.Columns.Add(boundColumn)

                        boundColumn = New TreeListBoundColumn()
                        boundColumn.DataField = "GP Address Id"
                        boundColumn.UniqueName = "GP Address Id"
                        boundColumn.HeaderText = "GP Address Id"
                        boundColumn.HeaderStyle.Width = "100"
                        boundColumn.ItemStyle.Width = "100"
                        RadTreeList1.Columns.Add(boundColumn)

                        boundColumn = New TreeListBoundColumn()
                        boundColumn.DataField = "GP Class Id"
                        boundColumn.UniqueName = "GP Class Id"
                        boundColumn.HeaderText = "GP Class Id"
                        'boundColumn.MinWidth = "120"
                        boundColumn.HeaderStyle.Width = "100"
                        boundColumn.ItemStyle.Width = "100"
                        RadTreeList1.Columns.Add(boundColumn)

                    End If

                    RadTreeList1.ClientSettings.Resizing.ResizeMode = TreeListResizeMode.AllowScroll
                    RadTreeList1.DataSource = reader
                    'RadTreeList1.AllowPaging = True
                    RadGrid1.Visible = False
                    RadGrid2.Visible = False
                    pnlDefalult.Visible = False
                    pnlListView.Visible = False
                    Panel1.Visible = True

                    RadTreeList1.Visible = True

       Protected Sub RadTreeList1_ItemDataBound(ByVal sender As Object, ByVal e As TreeListItemDataBoundEventArgs) Handles RadTreeList1.ItemDataBound

            Dim item As TreeListDataItem
            Dim ID As String
            If TypeOf e.Item Is TreeListDataItem Then

                item = TryCast(e.Item, TreeListDataItem)
                ID = DataBinder.Eval(item.DataItem, "UID")
                If ID.Contains("UID") Then
                    item.Item("GrpName").Font.Bold = True
                    If strGrpId <> "10" Then
                        item.Item("legal fees").Text = "&nbsp;"
                        item.Item("expenses").Text = "&nbsp;"
                        item.Item("discount").Text = "&nbsp;"
                        item.Item("% of legal fees").Text = "&nbsp;"
                        item.Item("Total").Text = "&nbsp;"
                    End If
                ElseIf ID.Contains("?") Then

                    If strGrpId <> "10" Then
                        item.Item("legal fees").Text = "&nbsp;"
                        item.Item("expenses").Text = "&nbsp;"
                        item.Item("discount").Text = "&nbsp;"
                        item.Item("% of legal fees").Text = "&nbsp;"
                        item.Item("Total").Text = "&nbsp;"
                    End If
                ElseIf ID.Contains("|") Then

                    If strGrpId <> "10" Then
                        item.Item("legal fees").Text = "&nbsp;"
                        item.Item("expenses").Text = "&nbsp;"
                        item.Item("discount").Text = "&nbsp;"
                        item.Item("% of legal fees").Text = "&nbsp;"
                        item.Item("Total").Text = "&nbsp;"
                    End If

                End If

            End If

        End Sub

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

.aspx

      <asp:Panel ID="Panel1" Visible="true" runat="server"  Height="700" Width="1350">
    

        <div>
        <asp:Button Text="Expand All" ID="Button2" runat="server" OnClick="expandall_click" Visible="false"  CssClass="button" />
     <asp:Button Text="Collapse All" ID="Button3" runat="server" OnClick="collapseall_click" Visible="false" CssClass="button" />
       <asp:Button Text="Expand first Grouping" ID="bntExpandToFirst" runat="server" OnClick="ExpandToFirst_click" Visible="false" CssClass="button" />
        </div>

           <telerik:RadTreeList  runat="server" ID="RadTreeList1" Width= "1150"  Height="600" AllowPaging="true" PageSize="500"  AllowStableSort="true" enablembeddedskins="false" 
           enablembeddedscripts="false"  ParentDataKeyNames="PID" DataKeyNames="UID" AutoGenerateColumns="false" AllowSorting="true" HeaderStyle-Font-Bold="true"   AllowMultiColumnSorting="true" ShowFooter="true" 
        OnItemCommand="RadTreeList1_ItemCommand" OnPageIndexChanged="RadTreeList1_PageIndexChanged"  OnItemCreated="RadTreeList1_ItemCreated"  AlternatingItemStyle-BackColor="White"
         PagerStyle-ChangePageSizeLabelText="Items Per Page:"   EnableViewState="false">
     
        <ClientSettings>
        <ClientEvents />
            <Resizing AllowColumnResize="true" EnableRealTimeResize="true" />
      
      
            <Scrolling AllowScroll="true"  UseStaticHeaders="true"  ScrollHeight="550" SaveScrollPosition="true" />
        </ClientSettings>

    </telerik:RadTreeList>
    </asp:Panel>

0
Pavlina
Telerik team
answered on 21 Jan 2013, 09:45 AM
Hi,

When creating a treelist dynamically that contains a template column, you must create the templates dynamically in the code-behind and assign them to the ItemTemplate, EditItemTemplate, etc. properties of the column.To create an ItemTemplate dynamically, you must define a custom class that implements the ITemplate interface. Then you can assign an instance of the class to the respective property of the TreeListTemplateColumn object. For more information about programmatic definition of RadTreeList control you can refer to this help article and online example.

All the best,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Priya
Top achievements
Rank 1
answered on 23 Jan 2013, 11:09 AM

Hi,
I already have custom class in my code but I forgot to mention, but still getting this error, but this error is inconsistent, I dont get this error everytime.

       Private Class ChkFirstInnerColumn
            Implements ITemplate
            Protected ChkFistInnerNodeId As Literal
            Private colName As String

            Public Sub New(ByVal cName As String)
                colName = cName
            End Sub

            Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) Implements ITemplate.InstantiateIn
                ChkFistInnerNodeId = New Literal
                ChkFistInnerNodeId.ID = "ChkFirstInnnerNode"
                AddHandler ChkFistInnerNodeId.DataBinding, AddressOf ChkFistInnerNodeId_DataBinding
                container.Controls.Add(ChkFistInnerNodeId)
            End Sub
            Private Sub ChkFistInnerNodeId_DataBinding(ByVal sender As Object, ByVal e As EventArgs)
                Dim lblChkOuterGrp As Literal = DirectCast(sender, Literal)
                Dim container As TreeListDataItem = DirectCast(lblChkOuterGrp.NamingContainer, TreeListDataItem)
                lblChkOuterGrp.Text = "<input class=checkbox type=checkbox id='chkOuterGrp" & container.DataItem("invoice").ToString() & "' name='chkOuterGrp' value='chkOuterGrp" & container.DataItem("invoice").ToString() & "' onclick='FnCheckAllOuterGroup(&#34;dv" & container.DataItem("invoice").ToString() & "&#34;,this)' " & getChecked("chkOuterGrp" & container.DataItem("invoice").ToString()) & "/>"

            End Sub

        End Class

   Private Class InvTemplColumn
            Implements ITemplate
            Protected InvView As Literal
            Private colName As String
            Private m_strGrpId As String

            Public Sub New(ByVal cName As String, ByVal i_strGrpId As String)
                colName = cName
                m_strGrpId = i_strGrpId
            End Sub

            Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) Implements ITemplate.InstantiateIn
                InvView = New Literal
                InvView.ID = "InvView"
                AddHandler InvView.DataBinding, AddressOf InvView_DataBinding
                container.Controls.Add(InvView)
            End Sub
            Private Sub InvView_DataBinding(ByVal sender As Object, ByVal e As EventArgs)
                Dim strdate As Date
                Dim ViewLink As Literal = DirectCast(sender, Literal)
                Dim container As TreeListDataItem = DirectCast(ViewLink.NamingContainer, TreeListDataItem)
  
                If container.DataItem("Date").ToString() = "" Then
                    ViewLink.Text = "&nbsp;" '"<IMG SRC='../Corpimages/icons/blank-green-flag-icon-2.png' border=0 valign='bottom' align='middle' >"

                ElseIf (m_strGrpId = "9" Or m_strGrpId = "10") And container.DataItem("Date").ToString() <> "" Then
                    strdate = container.DataItem("Date").ToString()
                    ViewLink.Text = "<a href ='afg_inv_overview.aspx?QInvId=" & container.DataItem("inv_id").ToString() & "'  target='_blank'><U>" & strdate.ToString("MM/dd/yyyy") & "</U></a>"  'target="_parent"  href='javascript:NavigatePage(" & Chr(34) & container.DataItem("inv_id").ToString() & Chr(34) & " ); '><U>View</U></a>"
                Else
                    ViewLink.Text = "<a href ='afg_inv_overview.aspx?QInvId=" & container.DataItem("inv_id").ToString() & "'  target='_blank'><U>" & container.DataItem("Invoice#").ToString() & "</U></a>"

                End If
            End Sub
        End Class

0
Pavlina
Telerik team
answered on 28 Jan 2013, 07:56 AM
Hello,

To be able to assist you further in resolving this error we will need to debug your application. Can you open a support ticket and send us a sample runnable project where the issue can be observed? Thus we will be able to investigate the problem in details and advice you further.

All the best,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
TreeList
Asked by
Priya
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Priya
Top achievements
Rank 1
Share this question
or