Ejemplo n.º 1
0
 private void BindGridColumns()
 {
     SelectorGrid.Columns.Clear();
     HyperLinkField selector = new HyperLinkField();
     selector.Text = "Выбрать";
     selector.ItemStyle.Width = new Unit(30, UnitType.Pixel);
     SelectorGrid.Columns.Add(selector);
     using (DictionaryProvider provider = new DictionaryProvider())
     {
         List<GridColumn> columns = provider.GetGridColumns(this.User.ID, DictionaryTreeID, FieldPlaceHolder.Grid);
         foreach (GridColumn item in columns)
         {
             ProductGridField field = new ProductGridField(item.Name, item.DataItem);
             field.SortExpression = item.DataItem;
             SelectorGrid.Columns.Add(field);
             SearchExpression expr = this.SearchConditions.FirstOrDefault(s => s.FieldID == item.ID);
             field.HeaderText = expr == null ? field.HeaderText : string.Format("{0} ({1})", field.HeaderText, expr.FieldValue);
         }
     }
 }
Ejemplo n.º 2
0
        protected void GridPager_CurrentPageChanged(object sender, PagerEventArgs e)
        {
            using (DictionaryProvider provider = new DictionaryProvider())
            {
                DictionaryTree entity = provider.DictionaryTrees.Single(d => d.ID == DictionaryTreeID);
                List<GridColumn> columns = provider.GetGridColumns(this.User.ID, DictionaryTreeID, FieldPlaceHolder.Grid);
                System.Data.DataSet source = provider.GetList(DictionaryTreeID, this.User.ID, this.OrderExpression,
                    this.SearchConditions, new PagingInfo(false));
                //provider.GetDictionaryDataSource(entity, SearchExp);
                ValueField = entity.PK;
                TextField = entity.Dictionary.IdentifierField;
                if (source != null && source.Tables.Count > 0)
                {
                    GridPager.Visible = SelectorGrid.Visible = true;
                    GridPager.CurrentPage = e.CurrentPage;
                    GridPager.TotalRecords = source.Tables[0].DefaultView.Count;

                    SelectorGrid.DataSource = source;
                    SelectorGrid.PageIndex = e.CurrentPage;
                    SelectorGrid.DataBind();
                    this.AppendGridHeader(columns);
                }
            }
        }