将查询条件传送到一个DataGrid显示页面后,需要将DataGrid重新绑定一次。

解决方案 »

  1.   

    当查询条件改变后,(dataset要更新)将DataGrid重新绑定一次
      

  2.   

    sub page_load()   if not ispostback then
           '数据绑定
       end ifend
      

  3.   

    sub page_load()   if not ispostback then
           '数据绑定
       end ifend当查询条件改变后,将DataGrid重新绑定。
      

  4.   

    DataSet thisDs=new DataSet();
    SqlDataAdapter thisAda=new SqlDataAdapter("select .........",conn);//conn为已打开的连接
    thisAda.Fill(ds);
    DataGrid1.DataSource=ds;
    DataGrid1.DataBind();
    conn.close();
      

  5.   

    当查询条件改变后,(dataset要更新)将DataGrid重新绑定一次
      

  6.   

    DataGrid改变数据源,比如删除、翻页等等后都要
    重新绑定
      

  7.   

    在Asp.net的内部机制里JavaScript的脚本会影响到整个web的运行机制.如果内
    部脚本发生的错乱,就会出现很多很奇怪的情况
      

  8.   

    代码如下:
    private void Page_Load(object sender, System.EventArgs e)
    {
       Sql_Str = (string)Session[Session.SessionID+"Sql_Str"];
       if(!Page.IsPostBack)
       {
         BindGrid();
       }
    }private void BindGrid()
    {
        DataSet daDetail=new DataSet();
        SqlConnection sqlConn=new SqlConnection(ConfigurationSettings.AppSettings[0]);
        SqlDataAdapter sqlDA=new SqlDataAdapter(Sql_Str,sqlConn);
        sqlConn.Open();
        sqlDA.Fill(daDetail,"wh_detail");
        sqlConn.Close();
        DataGrid1.DataSource=daDetail;
        DataGrid1.DataBind();
        Num_TB.Text=daDetail.Tables["wh_detail"].Rows.Count.ToString().Trim();
        sqlDA.Dispose();
        sqlConn.Dispose();
        daDetail.Dispose();
    }
       private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
    {
        DataGrid1.CurrentPageIndex=e.NewPageIndex;
        BindGrid();         
    }
      

  9.   

    Sql_Str 不是全局变量当然在DataGrid1_PageIndexChanged中绑定时就查不到内容了
      

  10.   

    你从什么地方看出Sql_Str 不是全局变量呢???
      

  11.   

    取得Session对象里Sql_Str查询字符串。
      

  12.   

    不要将绑定事件放在Load中,将绑定事件放在执行页面的最后一个事件Page_Pre中。
      

  13.   

    这样试试
    BindGrid();放外面,但这样做不太合理
    private void Page_Load(object sender, System.EventArgs e)
    {
       Sql_Str = (string)Session[Session.SessionID+"Sql_Str"];
        BindGrid();
    }
      

  14.   

    在BindGrid()
    里用Response.Write看看sql语句把。