hi dude,
For this you need to install 2007 Microsoft Tool then this will code will convert the data set into excel
In your page directive put
EnableEventValidation=false
public void ExportGridExel()
{
string attachment = "attachment; filename=EstablishmentAllotmentDetail.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
HtmlForm frm = new HtmlForm();
if (trAllotmentDetail.Visible == true)
{
pnlGrid.Parent.Controls.Add(frm);
frm.Controls.Add(pnlGrid);
}
if (trAllotmentDetailDivision.Visible == true)
{
pnlDivision.Parent.Controls.Add(frm);
frm.Controls.Add(pnlDivision);
}
frm.Attributes["runat"] = "server";
frm.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
}
public override void VerifyRenderingInServerForm(Control control)
{
}