sima_2n5k
دوشنبه 10 آبان 1389, 16:31 عصر
سلام
من میخوام اطلاعات grid بریزم داخل فایل اکسل اینم کدمه ولی به grid میرسه خطا میگیره که این داخل تگ فرم نیست؟! و کارایی که گفتنو انجام دادم مثل این که HtmlFormتعریف کتم و به فرم اضافش کنم یا VerifyRenderingInServerForm استفاده کنم که فقط اینا خطا رو نشون نمی دن ولی اجرام نمی شن!!!
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
Response.Clear();
Response.AddHeader("content-disposition", "attachment; filename=Financial.xls");
Response.Charset = "";
// If you want the option to open the Excel file without saving than
// comment out the line below
// Response.Cache.SetCacheability(HttpCacheability.No Cache);
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite =
new HtmlTextWriter(stringWrite);
GridView1.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
}
من میخوام اطلاعات grid بریزم داخل فایل اکسل اینم کدمه ولی به grid میرسه خطا میگیره که این داخل تگ فرم نیست؟! و کارایی که گفتنو انجام دادم مثل این که HtmlFormتعریف کتم و به فرم اضافش کنم یا VerifyRenderingInServerForm استفاده کنم که فقط اینا خطا رو نشون نمی دن ولی اجرام نمی شن!!!
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
Response.Clear();
Response.AddHeader("content-disposition", "attachment; filename=Financial.xls");
Response.Charset = "";
// If you want the option to open the Excel file without saving than
// comment out the line below
// Response.Cache.SetCacheability(HttpCacheability.No Cache);
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite =
new HtmlTextWriter(stringWrite);
GridView1.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
}