日期:2014-05-19  浏览次数:20610 次

100分--改错
细节上没任何问题的。
运行一些正常。
但是在分页的时候。
因为Page_Load里面默认的搜索一次数据。
当我使用条件搜索的时候。
触发了里面的分页事件。
于是搜索的数据点下一页的时候出现的确是没有搜索条件的默然数据。
问了以后才知道Page_Load里面应该写一个判断语句。但是我不知道怎么写。
100分求人指教一下。
<html>
<script   runat= "server "   language= "c# ">
protected   void   Page_Load(object   sender,   EventArgs   e)
{
string   strConnection= "Provider=Microsoft.Jet.OleDb.4.0;Data   Source= ";
strConnection+=Server.MapPath( "1.mdb ");

OleDbConnection   objConnection=new   OleDbConnection   (strConnection);

String   ee5= "update   jinhuo,DS_ClassInf   set   jinhuo.classname2=DS_ClassInf.classname   where   jinhuo.ClassID2=DS_ClassInf.ClassID ";
OleDbCommand   objCommand115   =   new   OleDbCommand(ee5,objConnection);
objCommand115.Connection.Open();
objCommand115.ExecuteNonQuery();
objCommand115.Connection.Close();

String   sql   =   "select   bianhao   as   教材编号,bookname   as   教材名称,shuliang   as   进货数量,booktime   as   进货时间,Classname   as   类别2,Classname2   as   类别1   from   jinhuo   ORDER   by   [booktime]   desc ";
DataSet   ds     =   new   DataSet();
OleDbDataAdapter   myada   =   new   OleDbDataAdapter(sql,strConnection);
myada.Fill(ds, "jinhuo ");
dgrdMain.DataSource   =   ds.Tables[ "jinhuo "].DefaultView;
dgrdMain.DataBind();  
  bianhao.Text= " ";
}

public   void   bind(object   sender,EventArgs   E)
{
string   strConnection= "Provider=Microsoft.Jet.OleDb.4.0;Data   Source= ";
strConnection+=Server.MapPath( "1.mdb ");

OleDbConnection   objConnection=new   OleDbConnection   (strConnection);

String   sql   =   "select   bianhao   as   教材编号,bookname   as   教材名称,shuliang   as   进货数量,booktime   as   进货时间,Classname   as   类别2,Classname2   as   类别1   from   jinhuo   where   bianhao= ' "   +   bianhao.Text   +   " '   and   format([booktime], 'yyyy-mm-dd   HH:mm:ss ')> = ' "+shijian1.Text+ " '   and   format([booktime], 'yyyy-mm-dd   HH:mm:ss ') <= ' "+shijian2.Text+ " '     ORDER   by   [booktime]   desc ";
DataSet   ds     =   new   DataSet();
OleDbDataAdapter   myada   =   new   OleDbDataAdapter(sql,strConnection);
myada.Fill(ds, "jinhuo ");
dgrdMain.DataSource   =   ds.Tables[ "jinhuo "].DefaultView;
dgrdMain.CurrentPageIndex=0;
dgrdMain.DataBind();
}
public   void   MyDataGrid_Page(object   sender,   System.Web.UI.WebControls.DataGridPageChangedEventArgs   e)
{
  dgrdMain.CurrentPageIndex   =   e.NewPageIndex;
  dgrdMain.DataBind();
}
</script>
<head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 "   />
<title> 无标题文档 </title>
<style   type= "text/css ">
<!--
.STYLE3   {font-size:   12px}
.STYLE5   {font-size:   9px}
-->
</style