Page.IsPostBack是什么意思? 如何判断页面是不是第一次被加载呢?

解决方案 »

  1.   

    if not Page.IsPostBack then
    end if
    Page.IsPostBack是指頁面被自己加載的事件。
      

  2.   

    if(String.Trim(txtStartTime.Text) != "")
    {
        //不空则取值
    }//继续下一个控件
    if(String.Trim(txtEndTime.Text) != "")
    {
        //不空则取值
    }
    ......
    ///这样不行嘛?
      

  3.   

    关键我要插入的是SQL的一句话,这样用IF太烦琐了,何况我有20多个TEXTBOX控件,和15个DropDownList控件,不能一个个判断。容易累死。
      

  4.   

    可以用Session来保存ASP.NET保持用户状态的九种选择
    http://www.yesky.com/SoftChannel/72342380468043776/20030610/1706647.shtml
      

  5.   

    如果数据库中的字段与控件命名有对应关系,如:数据库字段EndTime控件名txtEndTime,可以写一个通用函数解决这个问题。
      

  6.   

    不我不能用Session因为这个定义的对象太多了。容易引起一些错误。 EndTime 也没有对应的关系。现在就是想用一个查询语句。来全部查询,如果为空的话也可以进行查询,众所周知道。如果我对应的控件没有数据的话,那我就无法用Select * from b_new  where txtStartTime=""    这样是不可以的吧。。对不?
      

  7.   

    还有个问题就是如果我在
    public static strSelect="select * from b where pp='"+Session["userName"]+"'";
    没法写Seesion["userName"]这个对象,它告诉我Seesion["userName"]不是静态对象无法调用。怎么解决
      

  8.   

    不管是否为null,都传到存储过程(sp)去,然后加上以下判断即可:
    select *
    from talbe1
    where ((ID=@id and @id is not null) or (@id is null))
      

  9.   

    in sql you can use isnull to judge it
      

  10.   

    在存储过程里面可以如下做:@DepartmentID varchar(12)
    @PersonID varchar(12)
    @StartTime datetime
    @EndTime datetime以上是存储过程的参数
    过程中如下处理:
    declare @whereinfo = varchar(8000)set @whereinof = ' 1=1 '
    if(@DepartmentID is not null and @DepartmentID <> '')
    {
        set whereinof = whereinof  + 'departId = ' + @DepartmentID 
    }
    .....4个参数都如上处理最后调用exec('select * from ' + @whereinof )说白了,就是动态构造SQL
      

  11.   

    SORRY 
     set whereinof = whereinof  + 'departId = ' + @DepartmentID 
    --->  set whereinof = whereinof  + 'AND departId = ' + @DepartmentID