G
Guest
Hi,
I am exporting data from an EDITABLE DATA GRID EXCEL. But the 1st column
in data grid is Edit Column. I want to display all columns in Excel except
for the Edit column.
The following code which I am using allows exporting only from text data
from data grid & not from Edit columns which are link buttons. How to leave
this column while displaying data from data grid in Excel?
Code:
public void PerformExcelView()
{
Response.Clear();
Response.Buffer= true;
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
this.EnableViewState = false;
System.IO.StringWriter SW = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter HTW = new System.Web.UI.HtmlTextWriter(SW);
DataGrid1.RenderControl(HTW);
Response.Write(SW.ToString());
Response.End();
}
// From button click I am calling this function
private void btnExcel_Click(object sender, System.EventArgs e)
{
PerformExcelView();
}
Also, I tried to REMOVE theEDIT COLUMN on button click
.....DataGrid1.Columns.Remove(DataGrid1.Columns[0]);
& then calling the function PerfromExcelView() but I got the error:
"Index was out of range. Must be non-negative and less than the size of the
collection. Parameter name: index ".
How to get over this problem?
Any help will be appreciated .
Thanks
I am exporting data from an EDITABLE DATA GRID EXCEL. But the 1st column
in data grid is Edit Column. I want to display all columns in Excel except
for the Edit column.
The following code which I am using allows exporting only from text data
from data grid & not from Edit columns which are link buttons. How to leave
this column while displaying data from data grid in Excel?
Code:
public void PerformExcelView()
{
Response.Clear();
Response.Buffer= true;
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
this.EnableViewState = false;
System.IO.StringWriter SW = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter HTW = new System.Web.UI.HtmlTextWriter(SW);
DataGrid1.RenderControl(HTW);
Response.Write(SW.ToString());
Response.End();
}
// From button click I am calling this function
private void btnExcel_Click(object sender, System.EventArgs e)
{
PerformExcelView();
}
Also, I tried to REMOVE theEDIT COLUMN on button click
.....DataGrid1.Columns.Remove(DataGrid1.Columns[0]);
& then calling the function PerfromExcelView() but I got the error:
"Index was out of range. Must be non-negative and less than the size of the
collection. Parameter name: index ".
How to get over this problem?
Any help will be appreciated .
Thanks