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

Export columnn value instead of image (excel)

1 Answer 77 Views
Grid
This is a migrated thread and some comments may be shown as answers.
aykut
Top achievements
Rank 1
aykut asked on 01 Nov 2011, 10:19 AM
Dear friends,

I have a template column that shows images according to database value:

<ItemTemplate>
    <asp:Image runat="server" AlternateText="" ImageUrl="Images/ColdChain.png" Width="20px"
        Height="20px" Visible='<%#  iif ( SomeFunction(Eval("ColdChain")) ="", "false" , "true") %>' />
</ItemTemplate>


when exporting to excel, I want some text to be exported instead of image itself. For example I need "COLD" text in that column instead of image or image link itself.

how can I achieve this ?
thanks....

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 01 Nov 2011, 10:55 AM
Hello Aykut,

You can try the following code snippet.
C#:
protected void btn_Click(object sender, EventArgs e)
{
    RadGrid1.ExportSettings.ExportOnlyData = true;
    foreach (GridDataItem item in RadGrid1.Items)
    {
      TableCell cell = (TableCell)item["TemplateColumn"];
      cell.Text = "COLD";
    }
    RadGrid1.MasterTableView.ExportToExcel();
}

-Shinu.
Tags
Grid
Asked by
aykut
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or