Question

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>
Was it helpful?

Solution 3

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();
        }

    }

}

OTHER TIPS

Do you have any columns defined? or is AutoGenerateColumns == true

  1. categoriesBLL categoriesLogic = new categoriesBLL();

  2. GridView1.DataSource = categoriesLogic.GetCategories();

  3. GridView1.DataBind();

Change the line 2 to the following

GridView1.DataSource = categoriesLogic.Adapter.GetCategories();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top