This is a migrated thread and some comments may be shown as answers.
radgrid cast group item to griddataItem
3 Answers 73 Views
This is a migrated thread and some comments may be shown as answers.
turkush .
Top achievements
Rank 1
turkush . asked on 27 Jul 2011, 07:21 AM

GridGroupHeaderItem groupHeader = dtgLeads.MasterTableView.GetItems(GridItemType.GroupHeader)[index] as GridGroupHeaderItem;
  
GridItem[] children = groupHeader.GetChildItems();
bool hasChild = groupHeader.HasChildItems;
children.Count() > 0
  
flag = true;
foreach (GridItem child in children)
{}

I got error on (GridItem child in children) line. If i use GridDataItem in place of GridItem again i got error, I ve done this on trila version now we have Paid 2011 Q2 Ajax control version, now its not running. even the code is copied and pasted from the project that was runing with trial version.

Thanks

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 27 Jul 2011, 08:31 AM
Hello Turkush,

I am not quite sure about your requirement. Here is the sample code that I tried which worked on my end.

C#:
GridGroupHeaderItem item = (GridGroupHeaderItem)RadGrid1.MasterTableView.GetItems(GridItemType.GroupHeader)[0];
foreach (GridGroupHeaderItem groupHeader in RadGrid1.MasterTableView.GetItems(GridItemType.GroupHeader))
   {
     GridItem[] children = groupHeader.GetChildItems();
     foreach (GridDataItem child in children)
      {
     GridDataItem childItem = child as GridDataItem;
              //condition
      }
   }


Thanks,
Shinu.
0
turkush .
Top achievements
Rank 1
answered on 01 Aug 2011, 10:49 AM
Thanks for reply. I had tried ur mentioned solution. this gave me exception : Unable to cast object of type 'Telerik.Web.UI.GridGroupHeaderItem' to type 'Telerik.Web.UI.GridDataItem'.  On foreach (GridDataItem child in children) line of code
0
Andrey
Telerik team
answered on 04 Aug 2011, 02:02 PM
Hi Turkush .,

I have made you a sample project to illustrate how to fix the GridGroupHeaderItem-related issues.

Regards,
Andrey
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Asked by
turkush .
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
turkush .
Top achievements
Rank 1
Andrey
Telerik team
Share this question
or