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

Export to Excel Button Text

4 Answers 130 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 22 Oct 2013, 06:16 PM
Hi All!

Is there anyway to include some text to the left of the Export to Excel button icon in the top right of a RadGrid?  I do know that you can change the mouse-over text.

Thanks,
Mark

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 23 Oct 2013, 07:05 AM
Hi Mark,

One suggestion is to add a Literal Control next to the export button as shown below.

C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridCommandItem)
    {
        GridCommandItem cmd = (GridCommandItem)e.Item;
        Button btn = (Button)cmd.FindControl("ExportToExcelButton");
        LiteralControl lbl = new LiteralControl();
        lbl.Text = "ExportToExcel";
        lbl.ID = "lblExport";
        btn.Parent.Controls.AddAt(4,lbl);           
    }
}

Thanks,
Princy.
0
Mark
Top achievements
Rank 1
answered on 23 Oct 2013, 02:00 PM
Hi Princy,

The code worked perfectly!  Thanks!

Is there a way to make the lbl an extension of the Excel Button, so you can click on it as well to export? 

I could certainly switch lbl to a link button and make my own click event handler for the export.

Thanks,
Mark
0
Princy
Top achievements
Rank 1
answered on 24 Oct 2013, 06:56 AM
Hi Mark,

To obtain the Export on click of the text,you have to use LinkButton and instead of using the event handler you can set CommandName. Please move the code to ItemCreated event.Try the following code snippet.

C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridCommandItem)
    {
        GridCommandItem cmd = (GridCommandItem)e.Item;
        Button btn = (Button)cmd.FindControl("ExportToExcelButton");
        LinkButton lnk = new LinkButton();
        lnk.Text = "ExportToExcel";
        lnk.ID = "lnkExport";
        lnk.CommandName = "ExportToExcel";
        btn.Parent.Controls.AddAt(4, lnk);
    }
}

Thanks,
Princy
0
Mark
Top achievements
Rank 1
answered on 24 Oct 2013, 08:13 PM
Worked great!  Thanks a bunch!  :-)
Tags
Grid
Asked by
Mark
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Mark
Top achievements
Rank 1
Share this question
or