Exemple #1
0
        protected void BindDataToGridView()
        {
            //get data from database
            DataTable dt = AdminDb.GetAllListings(tbFindListing.Text, ddActiveFilter.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
            gvListings.DataSource = dv;
            gvListings.DataBind();
        }