0

Using Telerik RadGrid I'm binding a datasource and attach a method to the OnItemDataBound event.

<telerik:RadGrid ID="myGrid" runat="server"
    DataSourceID="myDataSource"
    OnItemDataBound="myMethod"
    >

I've been trying to find the solution for a while now with no luck. How could I check with the item being bound is the last item to be bound. For example, the below method will be called for each record

protected void myMethod(object sender, GridItemEventArgs e)
{
    //some condition to check whether the current item is the last
}

I hope if explained my problem clearly. Thank you in advance.

4

1 回答 1

3
if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)
{
    if (e.Item.DataSetIndex == e.Item.OwnerTableView.DataSourceCount - 1)
    {
        //Last Grid Item 
    }
}

If paging, to check the last item on the page:

(e.Item.ItemIndex == e.Item.OwnerTableView.PageSize - 1)
于 2012-06-19T14:47:45.617 回答