troubleshooting Question

Using SqlDatasource in DataSet mode to implement Paging gives error "The SqlDataSource 'SqlDataSourceGuestbook' does not have paging enabled. Set the DataSourceMode to DataSet to enable paging."

Avatar of dc197
dc197 asked on
.NET ProgrammingC#ASP.NET
10 Comments1 Solution4525 ViewsLast Modified:
I have an SqlDatasource control on my ASP.net page.  I wish to using it in DataSource mode, not dataread mode, to allow me to show just a few rows at a time using a DataList control.

The SqlDatasource is *definitely* in DataSet mode.  I set it at design time and at run time.

I get the below error:
The SqlDataSource 'SqlDataSourceGuestbook' does not have paging enabled.  Set the DataSourceMode to DataSet to enable paging.

The line that dies is the call to Select() here:

    protected void Page_Load(object sender, EventArgs e)
    {
        DataSourceSelectArguments soArgs = new DataSourceSelectArguments(0, 10);
        SqlDataSourceGuestbook.DataSourceMode = SqlDataSourceMode.DataSet;
        DataList1.DataSource = SqlDataSourceGuestbook.Select(soArgs);
        DataList1.DataBind();        
    }

NB. this is not yet finished, I will of course writie the paging parts to select rows 10 to 20, etc.  Obviously the above can be achieved using "select top 10 ..." but that's not what I want.

The datalist is defined:

   <asp:DataList ID="DataList1" runat="server"  >
       <ItemTemplate> .....       </ItemTemplate>
     .....
   </asp:DataList>

The SqlSource is:


       <asp:SqlDataSource ID="SqlDataSourceGuestbook" runat="server"
            DataSourceMode=DataSet
            ConnectionString="<%$ ConnectionStrings:DC_DSN %>"
             SelectCommand="SELECT  ......"
            >
             
       </asp:SqlDataSource>


Please help me to pull back just the first N rows.
ASKER CERTIFIED SOLUTION
REA_ANDREW

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros