protected void BindDataToGridView() { //get data from database DataTable dt = AdminDb.GetAllCities(tbFindCity.Text, ddMajorFilter.SelectedValue); //cast to dataview for sorting and filtering DataView dv = (DataView)dt.DefaultView; //sort by session expr and direction dv.Sort = Session["SortExpr"].ToString() + Session["SortDirection"].ToString(); //rebind with new sorted data gvCities.DataSource = dv; gvCities.DataBind(); }