티스토리 뷰

💼 정보 ver1.0

ListView + Datapager + Search

James Wetzel 2010. 7. 15. 20:24
728x90
반응형

        ListView1_PagePropertiesChanged를 꼭 추가하여 바인딩처리 해줘야지 페이지변경이후 데이터가 반영됨.

 

        ConnectionString = @"~~~~~~~~~~~~~~~~~~~~~~~";

        DBCommon cmn = new DBCommon();
        SqlQuery sq = new SqlQuery();
        protected void Page_Load(object sender, EventArgs e)
        {
            string searchText = "";
            if (ViewState["searchText"] != null)
            {
                searchText = ViewState["searchText"].ToString();
            }
            ListShow(searchText);
        }

        public void ListShow(string searchText)
        {
            string sql = "";
            cmn.DbConn(ConnectionString);
            sql = sq.SelectDefaultList(searchText);
            DataSet ds = cmn.GetDataSet(sql);
            ListView1.DataSource = ds;
            ListView1.DataBind();

            cmn.DbClose();
        }

        protected void ListView1_PagePropertiesChanged(object sender, EventArgs e)
        {
            string searchText = "";
            if (ViewState["searchText"] != null)
            {
                searchText = ViewState["searchText"].ToString();
            }
            ListShow(searchText);
        }

        protected void SearchBtn_Click(object sender, EventArgs e)
        {
            string searchText = SearchText.Text;
            ViewState["searchText"] = searchText;
            ListShow(searchText);
        }


728x90
반응형