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

Adding control in Grid header while displaying pivot data

4 Answers 115 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Amol
Top achievements
Rank 2
Amol asked on 18 Nov 2008, 03:42 PM
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


4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 19 Nov 2008, 06:48 AM
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.
0
Jagadeeswaran
Top achievements
Rank 1
answered on 01 Dec 2008, 01:58 PM
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.
0
Jagadeeswaran
Top achievements
Rank 1
answered on 02 Dec 2008, 06:28 AM
Please do the same in the grid prerender event..

Regards,
Jagadees
0
Yavor
Telerik team
answered on 02 Dec 2008, 06:32 AM
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.
Tags
Grid
Asked by
Amol
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Jagadeeswaran
Top achievements
Rank 1
Yavor
Telerik team
Share this question
or