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);
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>
The SqlSource is:
<asp:SqlDataSource ID="SqlDataSourceGuestbook" runat="server"
ConnectionString="<%$ ConnectionStrings:DC_DSN %>"
Please help me to pull back just the first N rows.