问题描述
这是页面的.cs文件publicpartialclassPages_finance_AX_SearchInfo:System.Web.UI.Page{DataSetds=newDataSet();//点击事件protectedvoidBtn_Search_Click(objectsender,EventArgse){if(this.DDL_Search_SelectSearchMode.SelectedItem.Text=="默认"){ds=search.searchAll(subject);this.GridView_Search.DataSource=ds;this.GridView_Search.DataBind();}if(this.DDL_Search_SelectSearchMode.SelectedItem.Text=="按科目"){ds=search.searchBySubject(subject);this.GridView_Search.DataSource=ds;this.GridView_Search.DataBind();}}//分页事件protectedvoidGridView_Search_PageIndexChanging(objectsender,GridViewPageEventArgse){this.GridView_Search.PageIndex=e.NewPageIndex;this.GridView_Search.DataSource=this.ds;this.GridView_Search.DataBind();}为什么报IListSource不包含任何数据源的错误呢是分页事件里的this.GridView_Search.DataBind();报的错好像是没有重新取数据,那具体代码怎么改一下呢?谢谢了
解决方案
解决方案二:
DataSetds=newDataSet();不要在外部声明DataSet,将邦定事件单独写成一个函数,随时调用
解决方案三:
我也想把绑定事件单独写成一个函数,但不太会写,有谁能发个上来参考一下,谢谢,谢谢