public static void BindGridView <T>(ASPnetControls.PagerV2_8 pager, GridView gridView, string sortExpression)
    {
        Type           type         = typeof(T);
        dynamic        activeRecord = new StaticMemberDynamicObject(type);
        IQueryable <T> obj          = activeRecord.All();

        pager.ItemCount     = obj.Count();
        gridView.DataSource = activeRecord.GetPaged(sortExpression,
                                                    pager.CurrentIndex,
                                                    gridView.PageSize);
        gridView.DataBind();
    }
Beispiel #2
0
    public static void BindDropDown <T>(DropDownList dropdown, string dataTextField, string dataValueField, bool addFirstEmptyItem = false)
    {
        dynamic        obj       = new StaticMemberDynamicObject(typeof(T));
        IQueryable <T> queryable = obj.All();

        dropdown.DataSource     = queryable.ToList();
        dropdown.DataTextField  = dataTextField;
        dropdown.DataValueField = dataValueField;
        dropdown.DataBind();

        if (addFirstEmptyItem)
        {
            dropdown.Items.Insert(0, String.Empty);
        }
    }