我在.net中有一个gridview,需要导出到excel / datable.Problem是 它包含文本框+下拉列表。这不适用于下拉列表
public void Persist(object sender, EventArgs e)
{
// GridViewExportUtil.Export("Customers.xls", this.grdData);
DataTable dt = new DataTable();
// add the columns to the datatable
if (grdData.HeaderRow != null)
{
for (int i = 0; i < grdData.HeaderRow.Cells.Count; i++)
{
dt.Columns.Add(grdData.HeaderRow.Cells[i].Text);
}
}
// add each of the data rows to the table
foreach (GridViewRow row in grdData.Rows)
{
DataRow dr;
dr = dt.NewRow();
for (int i = 0; i < row.Cells.Count; i++)
{
dr[i] = row.Cells[i].Text.ToString();
}
dt.Rows.Add(dr);
}