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

[Solved] Putting a Image button on RadGrid

1 Answer 165 Views
Grid
This is a migrated thread and some comments may be shown as answers.
anvesh amaravadi
Top achievements
Rank 1
anvesh amaravadi asked on 20 Nov 2009, 06:29 PM
Hi,

I want to put a ExportToExcel Button on top of the radgrid i.e. exactly beside the columns of the radgrid
The Button should show a image of Excel Icon
and by clicking it we can do the export to excel operation
I have got the functionality but i want to keep the button right on top of the gird beside the columns please help me     

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 23 Nov 2009, 06:20 AM
Hi Anvesh,

I am not quite sure about the requirement. You can try the following code snippet if you want to add the ImageButton to the header of grid beside the column headertext.

C# code:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    if (e.Item is GridHeaderItem) 
    { 
        GridHeaderItem headerItem = (GridHeaderItem)e.Item; 
        ImageButton ExportButton = new ImageButton(); 
        ExportButton.ID = "ExportButton1"
        ExportButton.ImageUrl = "~/Images/AddRecord.gif"
        ExportButton.Click += new ImageClickEventHandler(ExportButton_Click); 
        headerItem["ColumnUniquName"].Controls.AddAt(0, ExportButton); 
    } 
void ExportButton_Click(object sender, ImageClickEventArgs e) 
    RadGrid1.ExportSettings.ExportOnlyData = true
    RadGrid1.ExportSettings.OpenInNewWindow = true;       
    RadGrid1.MasterTableView.ExportToExcel();  

Feel free to share the comments,
Shinu.
Tags
Grid
Asked by
anvesh amaravadi
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or