0

このコードは、私のページでボタンがクリックされたときに実行されています:

protected void btnExportToPdfButton_click(object sender, EventArgs e)
{
    this.ProjectListGrid.ExportSettings.ExportOnlyData = true;
      this.ProjectListGrid.ExportSettings.Pdf.PageLeftMargin = Unit.Parse(".2in");
      this.ProjectListGrid.ExportSettings.Pdf.PageRightMargin = Unit.Parse(".2in");
    ApplyStylesToPdfExport(this.ProjectListGrid.MasterTableView);
    this.ProjectListGrid.MasterTableView.ExportToPdf();
}

public void ApplyStylesToPdfExport(GridTableView tableView)
{  
    // Get access to the header in the grid
    GridItem headerItem = tableView.GetItems(GridItemType.Header)[0];

    // Apply CSS Styles to the header
    headerItem.Style["font-size"] = "8pt";
    headerItem.Style["background-color"] = "#777";
    headerItem.Style["color"] = "white";

    // Apply CSS Styles to each cell in the header
    foreach (TableCell cell in headerItem.Cells)
    {
        cell.Style["color"] = "red";
    }
}

カスタムスタイルがまったく適用されていないだけで、pdfがエクスポートされます。私は自分が何を間違っているのか全くわかりません。

4

1 に答える 1

0

何らかの理由で、コントロールが再バインドされているように見えるため、インライン スタイルが消去されます。この動作の考えられる原因は、マークアップで ExportSettings.IgnorePaging をtrueに設定したことです。これが当てはまらず、まだこの問題がある場合は、ここにコードを投稿して、私が調べられるようにしてください。

于 2012-02-27T10:32:18.133 に答える