有一个DropDownList item[0]=0 item[1]=1
有一个GridView 分页
分页代码
  protected void gvData_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        gvData.PageIndex = e.NewPageIndex;
        BindData();
    }在Page_Load()
{
 BindData();
}这样分页的时候会执行2次BindData();
有于BindData()里面的查询条件用到了DropDownList的selectedValue
所以希望每次回传都重新刷新一次数据但是这样分页的时候 就有2次执行BindData()
有没有可能判断引起回传的是DropDownList还是GridView
要能做到
Page_Load()
{
if PostBack(DropDownList)
{
DataBind()
}
}

解决方案 »

  1.   

    啥意思呢,pageload里面加if(!IsPostBack){ DataBind();}不就可以了么
      

  2.   

    回传执行一次不能满足啊我的查询条件里面用到了DropDownList里面饿值
      

  3.   

    也就是DropDownList回传的时候 
    我希望重新绑定数据一次
      

  4.   

    pageload里面!IsPostBack绑定一次
    其他的绑定放到相应的事件处理代码里面啊
      

  5.   

    DropDownList里面是查询条件吧,你把查询条件写在DataBind里面撒然后在DropDownList的OnSelectedIndexChanged事件里面调用一下DataBind()不知道你是这意思不
      

  6.   

    查询条件里面用到了DropDownList里面饿值
    ======================
    使用DropDownList里面值查询完后再调用一下BindData();不就好了。
    if(!Page.IsPostBack)
    {
    }
    是不能少滴
      

  7.   

    DropDownList设置为AutoPostBack="true"
      

  8.   

    明白鸟!
    谢谢无疑 vmm
      

  9.   

    BindData(string strValue)strValue = DropDownList的selectedValue
    不可以吗?
      

  10.   

    if(!IsPostBack){ DataBind();}加dropdownlist事件里面调用DataBind();
      

  11.   

    private bool IsControlCausePostBack(string uniqueID)
    {
    return (!(Request.Form[uniqueID] == null)) || (!(Request.Form["__EVENTTARGET"] == null) && Request.Form["__EVENTTARGET"].Equals(uniqueID)) || ((!(Request.Form[uniqueID + ".x"] == null)) && (!(Request.Form[uniqueID + ".y"] == null)));
    }