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

GridFooterItem: DataItem

3 Answers 220 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sulman
Top achievements
Rank 1
Sulman asked on 28 Mar 2012, 10:17 AM
I am try to access the GridFooterItem on databound event and GridFooterItem.DataItem is nothing. 

Why I am getting Nothing for  "GridFooterItem.DataItem"?

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 28 Mar 2012, 10:42 AM
Hello Sulman,

Try the following code to access footer item in ItemDataBound event.
C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
   if (e.Item is GridFooterItem)
   {
     GridFooterItem footer = (GridFooterItem)e.Item;
   }
}

Thanks,
Shinu.
0
Sulman
Top achievements
Rank 1
answered on 28 Mar 2012, 11:02 AM
Hi,

I am actually talking about e.Item.DataItem for a footerdataitem type. 

I am getting e.Item.DataItem = Nothing. but I can see there is a value if tries to access the cells(0).text ('0' is just an example.). I needed to access that value with out any formatting applied. 
0
Accepted
Eyup
Telerik team
answered on 28 Mar 2012, 02:44 PM
Hi Sulman,

Generally, the footer in a grid is not defined as a DataItem, but as a FooterItem and this is the cause of the issue you are facing.

Indeed you can access the footer values as a DataItem using the code snippet below:
Protected Sub RadGrid1_ItemDataBound1(sender As Object, e As GridItemEventArgs)Handles RadGrid1.ItemDataBound
    If TypeOf e.Item Is GridFooterItem Then
        Dim footer As GridFooterItem = DirectCast(e.Item, GridFooterItem)
        Dim text As String = footer("ColumnUniqueName").Text
    End If
End Sub

For additional information on accessing cells and rows please refer to this article.

For further assistance, please inform us why you want to represent the FooterItem as a DataItem and what you want to achieve, so we can recommend you the most suitable approach.

Regards,
Eyup
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
Grid
Asked by
Sulman
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Sulman
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or