GridPagerItem in GridTableView

4 posts, 1 answers
  1. Jim
    Jim avatar
    2 posts
    Member since:
    Jan 2012

    Posted 09 Feb 2012 Link to this post

    I am trying to adapt this demo to customize the pager in a telerik:GridTableView
    http://demos.telerik.com/aspnet-ajax/grid/examples/programming/customizingpager/defaultcs.aspx

    I cannot figure out how to access the GridPagerItem in my GridTableView

    Thanks,
    JIm

  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 09 Feb 2012 Link to this post

    Hello Jim,

    Try the following code.
    c#:
    protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
     if(e.Item is GridPagerItem && e.Item.OwnerTableView.Name == "DetailTableName")
     {
       GridPagerItem PagerItem = (GridPagerItem)e.Item;
     }
    }

    -Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jim
    Jim avatar
    2 posts
    Member since:
    Jan 2012

    Posted 10 Feb 2012 Link to this post

    That works, e.Item.OwnerTableView.Name  was what i needed. Thanks for the prompt response.
  5. Gaurav
    Gaurav avatar
    5 posts
    Member since:
    Feb 2015

    Posted 18 Feb 2015 in reply to Shinu Link to this post

    Hi Shinu, I was not able to post a new thread so thought of adding to this one. I have gone a similar issue for casting from GridPagerItem to GridDataItem in the following code snippet. The strange part is that this worked in one instance and I could run my code. Now suddenly this one is not working. Any help is much appreciated.

    protected void SearchResultsUltraWebGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
        GridDataItem item = (GridDataItem)e.Item;
        SelectMember1(item);
    }

    The highlighted line is throwing the below error.

    {"Unable to cast object of type 'Telerik.Web.UI.GridPagerItem' to type 'Telerik.Web.UI.GridDataItem'."}
Back to Top