Exemplo n.º 1
0
        protected void CategoryDisplayGrid_Sorting(object sender, GridViewSortEventArgs e)
        {
            DataView sortedView;
            string   sortingDirection = string.Empty;

            if (direction == SortDirection.Ascending)
            {
                direction        = SortDirection.Descending;
                sortingDirection = "Desc";
            }
            else
            {
                direction        = SortDirection.Ascending;
                sortingDirection = "Asc";
            }


            ds = CategoryBLL.GetAllCategories();
            CategoryDisplayGrid.DataSource = ds;
            sortedView                     = new DataView(ds.Tables[0]);
            sortedView.Sort                = e.SortExpression + " " + sortingDirection;
            Session["SortedView"]          = sortedView;
            CategoryDisplayGrid.DataSource = sortedView;
            CategoryDisplayGrid.DataBind();
        }
Exemplo n.º 2
0
        private void BindGrid(bool isSearch)
        {
            if (ddlCatName.SelectedIndex != -1 && isSearch)
            {
                Category obj = new Category();
                obj.CategoryID = int.Parse(ddlCatName.SelectedValue);
                CategoryBLL ins = new CategoryBLL();
                ds = ins.GetById(obj);
            }
            else
            {
                ds = CategoryBLL.GetAllCategories();
            }
            CategoryDisplayGrid.DataSource = ds;
            CategoryDisplayGrid.DataBind();

            DropDownList depList = (DropDownList)CategoryDisplayGrid.FooterRow.FindControl("ddlAddDepName");

            depList.DataSource = DepartmentBLL.GetAllDepartment();
            depList.DataBind();
            depList.DataTextField  = "Name";
            depList.DataValueField = "DepId";
            depList.DataBind();
        }