0 Replies - 1455 Views - Last Post: 19 April 2014 - 05:42 PM Rate Topic: -----

#1 AaronHopkins   User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 180
  • Joined: 01-March 11

The data source does not support server-side data paging.

Posted 19 April 2014 - 05:42 PM

Been trying to configure the GridView to display ony 4 rows of data at a time. I thought it wasn't working because I forgot to set AllowPaging to True, but after I did that, I just get the error of
The data source does not support server-side data paging.
Source Error:
Line 66:          titlesGridView.DataBind(); // displays query results 

Here is my Books.aspx.cs code:
// Fig. 29.11: Books.aspx.cs
// Code-behind file for the password-protected Books page.
using System;
using System.Data.Entity;
using System.Linq;

namespace Bug2Bug.ProtectedContent
   public partial class Books : System.Web.UI.Page
      // Entity Framework DbContext
      BooksEntities dbcontext = new BooksEntities();

      // Load event handler for Books page
      protected void Page_Load(object sender, EventArgs e)
         // if this is the first time the page is loading
         if (!IsPostBack)
            dbcontext.Authors.Load(); // load Authors table into memory

            // LINQ query that populates authorsDropDownList
            var authorsQuery =
               from author in dbcontext.Authors.Local
               orderby author.LastName, author.FirstName
               select new
                  Name = author.LastName + ", " + author.FirstName,

            // specify the field used as the selected value
            authorsDropDownList.DataValueField = "AuthorID";

            // specify the field displayed in the DropDownList
            authorsDropDownList.DataTextField = "Name";

            // set authorsQuery as the authorsDropDownList's data source
            authorsDropDownList.DataSource = authorsQuery;

            authorsDropDownList.DataBind(); // displays query results
         } // end if
      } // end method Page_Load

      // display selected author's books
      protected void authorsDropDownList_SelectedIndexChanged(
         object sender, EventArgs e)
         dbcontext.Authors.Load(); // load Authors table into memory

         // use LINQ to get Author object for the selected author
         Author selectedAuthor =
            (from author in dbcontext.Authors.Local
             where author.AuthorID == 
             select author).First();

         // query to get books for the selected author
         var titlesQuery =
            from book in selectedAuthor.Titles
            orderby book.Title1
            select book;

         // set titlesQuery as the titlesGridView's data source
         titlesGridView.DataSource = titlesQuery;
         titlesGridView.DataBind(); // displays query results  

      protected void titlesGridView_SelectedIndexChanged(object sender, EventArgs e)

      } // end method authorsDropDownList_SelectedIndexChanged
   } // end class Books
} // end namespace Bug2Bug.ProtectedContent

<%@ Page Title="Books" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Books.aspx.cs" Inherits="Bug2Bug.ProtectedContent.Books" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server">
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
      Select author:&nbsp;
      <asp:DropDownList ID="authorsDropDownList" runat="server" AutoPostBack="True" onselectedIndexChanged="authorsDropDownList_SelectedIndexChanged">
      <asp:GridView ID="titlesGridView" runat="server" CellPadding="5" ForeColor="#333333" GridLines="None" AllowPaging="True" AllowSorting="True" onselectedIndexChanged="titlesGridView_SelectedIndexChanged" PageSize="4" Width="600px">
         <AlternatingRowStyle BackColor="LightYellow" ForeColor="#284775" />
         <EditRowStyle BackColor="#999999" />
         <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
         <HeaderStyle BackColor="LightGreen" Font-Bold="True" ForeColor="White" />
         <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
         <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
         <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
         <SortedAscendingCellStyle BackColor="#E9E7E2" />
         <SortedAscendingHeaderStyle BackColor="#506C8C" />
         <SortedDescendingCellStyle BackColor="#FFFDF8" />
         <SortedDescendingHeaderStyle BackColor="#6F8DAE" />

Any help in what I am missing or doing wrong?

Is This A Good Question/Topic? 0
  • +

Page 1 of 1