寻呼机点击

时间:2015-08-12 20:07:41

标签: c# asp.net

我有一个列表视图,寻呼机和一个文本框,允许用户输入一个值来填充列表视图。在ListView加载时,如果我输入一个值来搜索它工作正常。但是,如果在加载后,我点击" next"在寻呼机上,我的搜索功能无法正常工作。我必须点击我的"搜索"按钮两次以获得正确的结果:

ASPX:

<asp:ListView ID="ReviewCaseStatusListView" runat="server"  OnPagePropertiesChanging="ListEvents_PagePropertiesChanging" >

C#

 protected void BindListView()
    {

            CaseUploadHistoryLabel.Visible = false;
            using (var Apptestconn = new SqlConnection(ConfigurationManager.ConnectionStrings["Apptestconn"].ConnectionString))
            {
                Apptestconn.Open();

                if (CaseStatusDropDownList.SelectedValue == "" & CaseNumberTextBox.Text == "" & StartDateTextBox.Text == "" & EndDateTextBox.Text == "")
                {
                    using (SqlCommand cmdGetAllCaseInformationSP = new SqlCommand("GetAllCaseInformationSP", Apptestconn))
                    {
                        cmdGetAllCaseInformationSP.CommandType = CommandType.StoredProcedure;
                        cmdGetAllCaseInformationSP.Parameters.AddWithValue("@UserName", "nguyenlc");
                        cmdGetAllCaseInformationSP.ExecuteNonQuery();

                        SqlDataAdapter da = new SqlDataAdapter(cmdGetAllCaseInformationSP);
                        DataSet ds = new DataSet();
                        da.Fill(ds, "GetAllCaseInformationTable");
                        ReviewCaseStatusListView.DataSource = ds.Tables["GetAllCaseInformationTable"];
                        ReviewCaseStatusListView.DataBind();


                        if (ds.Tables["GetAllCaseInformationTable"].Rows.Count != 0)
                        {

                            CaseUploadHistoryLabel.Visible = true;

                        }

                    }
                }


    protected void ListEvents_PagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e)
    {
        //set current page startindex, max rows and rebind to false
        DataPager pager = ReviewCaseStatusListView.FindControl("DataPager1") as DataPager;
        pager.SetPageProperties(e.StartRowIndex, e.MaximumRows, false);

        //rebind List View
        BindListView();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            BindListView();
        }

    }

    protected void SearchButton_Click(object sender, EventArgs e)
    {

            BindListView();

    }
}

0 个答案:

没有答案