从GridView中删除列

时间:2009-08-01 06:48:36

标签: c# asp.net itextsharp

我有一个包含几列的GridView,我不想将其导出为PDF(通过iTextSharp)。

如何在导出数据之前隐藏我不想导出的列?

2 个答案:

答案 0 :(得分:8)

在导出数据之前,请执行以下操作:

myGridView.columns.RemoveAt(index);    //Index is the index of the column you want to remove
myGridView.Databind();

答案 1 :(得分:1)

或尝试

  dataGridView1.Columns[index].Visible = false; // the index of the column to be hidden