当前位置: 首页 > news >正文

海淀网站建设/哪个平台可以接推广任务

海淀网站建设,哪个平台可以接推广任务,网络优化工程师证书,群晖wordpress更改端口为什么80%的码农都做不了架构师&#xff1f;>>> 当用GridView导出Execl的时候&#xff0c;会发生只能在执行 Render() 的过程中调用 RegisterForEventValidation的错误提示。 有两种方法可以解决以上问题&#xff1a; 1.修改web.config(不推荐)<pages enableEve…

为什么80%的码农都做不了架构师?>>>   hot3.png

当用GridView导出Execl的时候,会发生只能在执行 Render() 的过程中调用 RegisterForEventValidation的错误提示。
有两种方法可以解决以上问题:
1.修改web.config(不推荐)<pages enableEventValidation ="false" ></pages>
2.直接在导出Execl的页面修改

<%@ Page Language="C#" EnableEventValidation = "false" AutoEventWireup="true"

CodeFile="ExportGridView.aspx.cs" Inherits="ExportGridView" %>
附:Gridview导出Execl可分页全部导出代码(C#)

None.gifusing System;
None.gifusing System.Data;
None.gifusing System.Configuration;
None.gifusing System.Collections;
None.gifusing System.Web;
None.gifusing System.Web.Security;
None.gifusing System.Web.UI;
None.gifusing System.Web.UI.WebControls;
None.gifusing System.Web.UI.WebControls.WebParts;
None.gifusing System.Web.UI.HtmlControls;
None.gifusing System.Data.SqlClient;
None.gifusing System.IO;
None.gif
None.gifpublic partial class EXportTest : System.Web.UI.Page
ExpandedBlockStart.gif{
InBlock.gif protected void Page_Load(object sender, EventArgs e)
ExpandedSubBlockStart.gif {
InBlock.gif if (!Page.IsPostBack)
ExpandedSubBlockStart.gif {
InBlock.gif            BindData(); 
ExpandedSubBlockEnd.gif        }
InBlock.gif
ExpandedSubBlockEnd.gif    }
InBlock.gif
InBlock.gif private string ConnectionString
ExpandedSubBlockStart.gif {
InBlock.gif
ExpandedSubBlockStart.gif get { return @"Server=localhost;Database=Northwind;
ExpandedSubBlockEnd.gif        Trusted_Connection=true"; }
InBlock.gif
ExpandedSubBlockEnd.gif    }
InBlock.gif
InBlock.gif
InBlock.gif
InBlock.gif private void BindData()
ExpandedSubBlockStart.gif {
InBlock.gif // make the query 
InBlock.gif string query = "SELECT * FROM Categories";
InBlock.gif        SqlConnection myConnection = new SqlConnection(ConnectionString);
InBlock.gif        SqlDataAdapter ad = new SqlDataAdapter(query, myConnection);
InBlock.gif        DataSet ds = new DataSet();
InBlock.gif        ad.Fill(ds, "Categories");
InBlock.gif        GridView1.DataSource = ds;
InBlock.gif        GridView1.DataBind(); 
InBlock.gif
ExpandedSubBlockStart.gif /* It's a good idea if you can Cache the DataSet */
InBlock.gif
ExpandedSubBlockEnd.gif    }
InBlock.gif
InBlock.gif public override void VerifyRenderingInServerForm(Control control)
ExpandedSubBlockStart.gif {
InBlock.gif
InBlock.gif // Confirms that an HtmlForm control is rendered for
InBlock.gif        the specified ASP.NET server control at run time.
InBlock.gif
ExpandedSubBlockEnd.gif    }
InBlock.gif
InBlock.gif protected void Button1_Click(object sender, EventArgs e)
ExpandedSubBlockStart.gif {
InBlock.gif        Response.Clear();
InBlock.gif
InBlock.gif        Response.AddHeader("content-disposition",
InBlock.gif "attachment;filename=FileName.xls");
InBlock.gif
InBlock.gif        Response.Charset = "";
InBlock.gif
InBlock.gif // If you want the option to open the Excel file without saving than
InBlock.gif
InBlock.gif // comment out the line below
InBlock.gif
InBlock.gif // Response.Cache.SetCacheability(HttpCacheability.NoCache);
InBlock.gif
InBlock.gif        Response.ContentType = "application/vnd.xls";
InBlock.gif
InBlock.gif        System.IO.StringWriter stringWrite = new System.IO.StringWriter();
InBlock.gif
InBlock.gif        System.Web.UI.HtmlTextWriter htmlWrite =
InBlock.gif new HtmlTextWriter(stringWrite);
InBlock.gif
InBlock.gif // turn off paging 
InBlock.gif        GridView1.AllowPaging = false;
InBlock.gif        BindData(); 
InBlock.gif
InBlock.gif
InBlock.gif        GridView1.RenderControl(htmlWrite);
InBlock.gif
InBlock.gif        Response.Write(stringWrite.ToString());
InBlock.gif
InBlock.gif        Response.End();
InBlock.gif
InBlock.gif // turn the paging on again 
InBlock.gif        GridView1.AllowPaging = true;
InBlock.gif        BindData();
InBlock.gif
ExpandedSubBlockEnd.gif    }
InBlock.gif
InBlock.gif protected void GridView1_PageIndexChanging(object sender,
InBlock.gif    GridViewPageEventArgs e)
ExpandedSubBlockStart.gif {
InBlock.gif        GridView1.PageIndex = e.NewPageIndex;
InBlock.gif        BindData(); 
ExpandedSubBlockEnd.gif    }
ExpandedBlockEnd.gif}

转载于:https://my.oschina.net/wzzz/blog/186053

相关文章:

  • 放单平台/网络优化seo是什么工作
  • 建站软件免费模板/长春网络优化最好的公司
  • 校园电商平台网站建设/网络优化基础知识
  • 什么网站能赚钱/广州网络优化最早的公司
  • 国内b2b常用的平台有哪些/长沙seo网络优化
  • 给朋友做的相册网站没有了/seo网络优化培训
  • 商务网站建设服务商/网络优化工具
  • 建设通银行官方网站/武汉seo网络优化公司
  • 公司网页制作html/网络优化工作应该怎么做
  • 珠海seo网站建设/东莞网络优化哪家公司好
  • 商务网站建设服务商/网络优化工具
  • 镇江seo优化/江苏泰州seo网络优化推广