Search code examples
c#asp.netgridviewbusiness-logic-layer

gridview not showing values via BLL?


My control doesnt return the values in my gridview.

table adapter runs the query fine and displays the data.

Here is my code from the control:

 categoriesBLL categoriesLogic = new categoriesBLL();
 GridView1.DataSource = categoriesLogic.GetCategories();
 GridView1.DataBind();

and here is my BLL:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NopSolutions.NopCommerce.Nop.DataAccess.MegaProductMenuTableAdapters;

namespace NopSolutions.NopCommerce.BusinessLogic.MegaProductsMenu
{
    [System.ComponentModel.DataObject]
    public class categoriesBLL
    {

        private Nop_CategoryTableAdapter _categoriesAdapter = null;
        protected Nop_CategoryTableAdapter Adapter
        {
            get
            {
                if (_categoriesAdapter == null)
                    _categoriesAdapter = new Nop_CategoryTableAdapter();

                return _categoriesAdapter;
            }
        }



        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
        public Nop_CategoryTableAdapter GetCategories()
        {
            return _categoriesAdapter;
        }


    }

}

My DAL looks like this:

enter image description here

If connect directly to the DAL I can get the values to show up. So i think there is something wrong with my BLL, but what could it be? I receive no error messages.

My gridview source:

    <asp:GridView ID="GridView1" runat="server" CssClass="DataWebControlStyle" AutoGenerateColumns="True">
       <HeaderStyle CssClass="HeaderStyle" />
       <AlternatingRowStyle CssClass="AlternatingRowStyle" />
    </asp:GridView>

Solution

  • I solved this by asigning the datatable:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using NopSolutions.NopCommerce.Nop.DataAccess.MegaProductMenuTableAdapters;
    
    namespace NopSolutions.NopCommerce.BusinessLogic.MegaProductsMenu
    {
        [System.ComponentModel.DataObject]
        public class categoriesBLL
        {
    
            private Nop_CategoryTableAdapter _categoriesAdapter = null;
            protected Nop_CategoryTableAdapter Adapter
            {
                get
                {
                    if (_categoriesAdapter == null)
                        _categoriesAdapter = new Nop_CategoryTableAdapter();
    
                    return _categoriesAdapter;
                }
            }
    
            [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
            public NopCommerce.Nop.DataAccess.MegaProductMenu.Nop_CategoryDataTable GetCategories()
            {
                return Adapter.GetCategories();
            }
    
        }
    
    }