using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ShowData();
string dbcon = ConfigurationManager.ConnectionStrings["cn"].ToString();
}
public override void VerifyRenderingInServerForm(Control control)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Clear();
Response.BufferOutput = false;
string archiveName = "customer.xls";
Response.ContentType = "application/zip";
Response.AddHeader("content-disposition", "filename=" + archiveName);
Response.Charset = "";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
GridView1.AllowPaging = false; GridView1.DataBind();
GridView1.HeaderRow.Style.Add("background-color", "#FFFFFF");
GridView1.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
}
public void ShowData()
{
SqlDataAdapter adp = new SqlDataAdapter("select catname,catid,creationdate,pagename from quizcats ", ConfigurationManager.ConnectionStrings["cn"].ConnectionString);
DataSet ds = new DataSet();
adp.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
}