Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

When the DataBoundControl has paging enabled, either the SelectMethod should return an IQueryable

$
0
0

I have something odd going on. 

This was working fine, until I added an update method to my code behind. I don't understand what its changed.

My select method does return iqueryable supplier - but when I put I breakpoint it seems it never even enters the select method. Can someone help me out here as I have been stuck with this for days now.

Error:

When the DataBoundControl has paging enabled, either the SelectMethod should return an IQueryable<ItemType> or should have all these mandatory parameters : int startRowIndex, int maximumRows, out int totalRowCount

Select method:

// The return type can be changed to IEnumerable, however to support
        // paging and sorting, the following parameters must be added:
        //     int maximumRows
        //     int startRowIndex
        //     out int totalRowCount
        //     string sortByExpression
        public IQueryable<supplier> GridView1_GetData()
        {

            SupplierDBModel context = new SupplierDBModel();
            return (from s in context.suppliers
                    select s).AsQueryable();
        }

Grid:

<asp:GridView ID="GridView1" CssClass="table table-hover table-striped" SelectMethod="GridView1_GetData" DeleteMethod="GridView1_DeleteItem" UpdateMethod="GridView1_UpdateItem" AllowPaging="True"  AllowSorting="True" ItemType="PrincePortalWeb.Models.supplier" runat="server" AutoGenerateEditButton="True" AutoGenerateDeleteButton="True"              
            AutoGenerateSelectButton="True"  AutoGenerateColumns="False" ShowFooter="True"  DataKeyNames="supplierid" ><Columns><asp:BoundField DataField="supplierid" HeaderText="ID" /><asp:BoundField ApplyFormatInEditMode="True" DataField="suppliername" HeaderText="Customer"><HeaderStyle Font-Bold="True" HorizontalAlign="Center" /><ItemStyle HorizontalAlign="Center" /></asp:BoundField><asp:BoundField DataField="status" HeaderText="Status"><HeaderStyle Font-Bold="True" HorizontalAlign="Center" /><ItemStyle HorizontalAlign="Center" /></asp:BoundField><asp:BoundField DataField="whencompliant.date" HeaderText="When Compliant" /><asp:BoundField DataField="reviewdate.date" HeaderText="Review Date" /><asp:BoundField DataField="lastreviewedby" HeaderText="Reviewed By" /><asp:BoundField DataField="webstatus" HeaderText="Portal Status" /></Columns>

Supplier context and class:

    public partial class SupplierDBModel : DbContext
    {




        public SupplierDBModel()
            : base("name=SupplierDBModel")
        {


            // Database.SetInitializer(new MigrateDatabaseToLatestVersion<SupplierDBModel, EF6Console.Migrations.Configuration>());


        }

        public virtual DbSet<supplier> suppliers { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
        }

    }

        public partial class supplier 
        {


            public int supplierid { get; set; }

            [Required]
            [StringLength(50)]
            public string suppliername { get; set; }

            [StringLength(50)]
            public string address1 { get; set; }

            [StringLength(50)]
            public string county { get; set; }

            [StringLength(50)]
            public string country { get; set; }

            [StringLength(50)]
            public string telephone { get; set; }

            [StringLength(50)]
            public string address2 { get; set; }

            [StringLength(11)]
            public string postcode { get; set; }

            [StringLength(20)]
            public string webstatus { get; set; }

           
            public status status { get; set; }

            [StringLength(50)]
            public string LastreviewedBy { get; set; }

            [Column(TypeName = "datetime2")]
            public DateTime Whencompliant { get; set; }
            [Column(TypeName = "datetime2")]
            public DateTime Reviewdate { get; set; }



        }

    public enum status
    {
        Compliant,
        In_Progress,
        Not_Started,


    }

    }

Thank you


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>