Adding control in Grid header while displaying pivot data

5 posts, 0 answers
  1. Amol
    Amol avatar
    57 posts
    Member since:
    Apr 2008

    Posted 18 Nov 2008 Link to this post

    I am displaying pivot data in grid as in the example Grid/Examples/Programming/Pivot/DefaultCS.aspx .

    Now i want to add ImageButton Control with postback url in the grid header.

    Can anyone suggest me a way to do so.

    Thanks


  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 19 Nov 2008 Link to this post

    Hello Amol,

    You can try out the following code to add an ImageButton in the grid header(Pivot Data).
    cs:
     protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
        { 
           if (e.Item is GridHeaderItem) 
            { 
                GridHeaderItem header = (GridHeaderItem)e.Item; 
                ImageButton imgBtn = new ImageButton(); 
                imgBtn.ImageUrl = "images (2)/New Bitmap Image.bmp"
                imgBtn.PostBackUrl = "Default2.aspx"
                header[(RadGrid1.MasterTableView.AutoGeneratedColumns[1] as GridBoundColumn).UniqueName].Controls.Add(imgBtn); 
                 
            } 
        } 

    Thanks
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jagadeeswaran
    Jagadeeswaran avatar
    2 posts
    Member since:
    Nov 2008

    Posted 01 Dec 2008 Link to this post

    Hi,

    I did the same way as mentioned above, but the sorting is not working properly.
    When I click first time the column sorts "asc" and the image also shown up. But if I click on the same column to sort in "desc" does not work.
    This doesn't throw any error and the sort icon still shows "asc".

    Please help to resolve this issue.
    Thanks in advance.

    Regards,
    Jagadees.
  5. Jagadeeswaran
    Jagadeeswaran avatar
    2 posts
    Member since:
    Nov 2008

    Posted 02 Dec 2008 Link to this post

    Please do the same in the grid prerender event..

    Regards,
    Jagadees
  6. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 02 Dec 2008 Link to this post

    Hi Jagadeeswaran,

    Indeed, since the itemdatabound event handler is not raised on each lifecycle for the control, whereas the PreRender event handler is, you can utilize the PreRender event handler, and get a reference to the header item, to add any necessary items.

    Best wishes,
    Yavor
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017