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

100分--我又来了
依然是分页的问题。
还请各位大哥不要说喊我去论坛搜起自己看。我送分的啊。
论坛的我都看的差不多了。好多都是语言不怎么通,而且好多都是自己做函数来分页。我这里用的控件的。只是出错而已。
尝试,打开页面显示全部数据。
第搜索时,分页也应该正常。但是这里的bind()出错了。
提示:重载“bind”方法未获取“0”参数
数据连接与细节是没错的。只是这里怎么传递参数不会。
小弟是自学。纯熟菜鸟级人物。还望各位说详细点。


<script   runat= "server "   language= "c# ">
protected   void   Page_Load(object   sender,   EventArgs   e)
{
if(!IsPostBack)
{
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();
}
else
{
bind();
}

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;
  DataBind();
}
</script>
<asp:Button   ID= "Button1 "   Text= "开始查询 "   OnClick= "bind "   runat= "server "   />
<asp:DataGrid   AllowCustomPaging= "false "   AllowPaging= "true "   BorderColor= "#999999 "   BorderWidth= "1 "   CellPadding= &quo