title: Formatting radgrid exporting to PDF
body: <p>I have a datatable dt, and want to make a PDF file from it. Everything is dynamic and it works but I can't format the layout such as alternate row background etc. Here is my code :</p>
  
  <pre><code>   private void MakeGridExportToPDF(string strTitle, DataTable dt)
  {
      using (RadGrid grid = new RadGrid { AutoGenerateColumns = false, ShowHeader = true, })
      {
          grid.NeedDataSource += (object sender, GridNeedDataSourceEventArgs e) =&gt;
                {
                    grid.DataSource = dt;
                };
          // Add columns
          dt.Columns.OfType&lt;DataColumn&gt;().ToList().ForEach(col =&gt;
          {
              grid.MasterTableView.Columns.Add(new GridBoundColumn { DataField = col.ColumnName, HeaderText = col.Caption.ToCamel() });
          });
          GridExportSettings export = grid.ExportSettings;
          export.OpenInNewWindow = true;
          export.FileName = strTitle;
          export.IgnorePaging = true;
          GridPdfSettings pdf = export.Pdf;
          pdf.PageHeight = Unit.Parse("210mm"); // 
          pdf.PageWidth = Unit.Parse(GetPageWidth(grid.MasterTableView.Columns.Count)); // 
          pdf.DefaultFontFamily = "Arial Unicode MS";
          pdf.PageTopMargin = Unit.Parse("45mm");
          grid.ItemCreated += (object sender, GridItemEventArgs e) =&gt;
           {
               GridItem item = e.Item;
               if (item is GridDataItem)
               {
                   item.Style["vertical-align"] = "middle";
                   item.Style["text-align"] = "center";
               }
               switch (item.ItemType) //Mimic RadGrid appearance for the exported PDF file
               {
                   case GridItemType.Item:
                       item.Style["background-color"] = "#DFDFDF";
                       item.Font.Italic = true;
                       break;
                   case GridItemType.AlternatingItem:
                       item.Style["background-color"] = "#FFFFFF";
  
                       break;
                   case GridItemType.Header:
                       item.Style["background-color"] = "#FFFFFF";
                       item.Style["Color"] = "#767676";
                       item.Font.Bold = true;
                       break;
                   case GridItemType.Footer:
                       item.Style["background-color"] = "#FFFFFF";
  
  
                       break;
               }
           };
  
          this.smCSVFile.Controls.Add(grid);
          grid.MasterTableView.ExportToPdf();
          bDone = true;
      }
  }
  </code></pre>
  
  <p>What am I doing wrong. the ItemCreated is triggered when grid is created first but not when is exported and don't see any changes. Any help would be greatly appreciated.  </p>