/// <summary> /// ��Grid /// </summary> protected void BindGrid() { HEemployeeBB eemployeeBB = new HEemployeeBB(); DataSet ds = new DataSet(); try { string strWhere = this.StrWhere; if (this.empNo.Text != "") { strWhere += " and empNo like '%" + this.empNo.Text + "%'"; } if (this.empNm.Text != "") { strWhere += " and empNm like '%" + this.empNm.Text + "%'"; } if (this.nowDepartId.Value != "") { strWhere += " and nowDepartId =" + this.nowDepartId.Value; } if (this.gender.SelectedValue != "") { strWhere += " and gender ='" + this.gender.SelectedValue + "'"; } if (this.role.SelectedValue != "") { strWhere += " and ','+roleIds+',' like '%," + this.role.SelectedValue + ",%'"; } ds = eemployeeBB.GetVList(strWhere); this.grid.DataSource = ds.Tables[0]; this.grid.DataBind(); //��ֵ��¼������ҳ������ this.Label3.Text = ds.Tables[0].Rows.Count.ToString(); this.Label2.Text = this.grid.PageCount.ToString(); this.currPage.Text = (this.grid.PageIndex + 1).ToString(); } finally { eemployeeBB.Dispose(); } }
/// <summary> /// 绑定数据源 /// </summary> private void BindGrid() { string strWhere = this.StrWhere; if (this.empNo.Text != "") { strWhere += " and empNo like '%" + this.empNo.Text + "%'"; } if (this.empNm.Text != "") { strWhere += " and empNm like '%" + this.empNm.Text + "%'"; } if (this.drDepart.SelectedValue != "") { strWhere += " and nowDepartId = " + this.drDepart.SelectedValue; } if (this.drRole.SelectedValue != "") { strWhere += " and exists(select 1 from PUserRole where empId=vHEemployee.empId and roleId=" + this.drRole.SelectedValue + ")"; } HEemployeeBB userBB = new HEemployeeBB(); DataSet ds = new DataSet(); try { ds = userBB.GetVList(strWhere); this.grid.DataSource = ds.Tables[0]; this.grid.DataBind(); //赋值记录条数、页面总数 this.Label3.Text = ds.Tables[0].Rows.Count.ToString(); this.Label2.Text = this.grid.PageCount.ToString(); this.currPage.Text = (this.grid.PageIndex + 1).ToString(); } finally { userBB.Dispose(); } }