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

Excel Export formatting for Templated Columns

1 Answer 72 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Darek
Top achievements
Rank 1
Darek asked on 19 Oct 2011, 02:08 AM
How does one control Excel cell formatting for a templated column based on a value? The documentation states that one can use

double.Parse(e.Cell.Text) < 0

but Cell.Text is empty for a GridTemplateColumn ...

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 19 Oct 2011, 08:14 AM
Hello Darek,

One suggestion is to access the control in the TemplateColumn and access the value. Here is the sample code.
C#:
protected void RadGrid1_ExportCellFormatting(object sender, ExportCellFormattingEventArgs e)
{
    GridDataItem item = e.Cell.Parent as GridDataItem;
    if (e.FormattedColumn.UniqueName == "MyColumn"  )
    {
         TextBox txt = (TextBox)item["MyColumn"].FindControl("Txt1");
         string str = item["MyColumn"].Text;
         if (txt.Text == "Welcome")
       
        }
     }
}

Thanks,
Shinu.
Tags
Grid
Asked by
Darek
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or