(reposted with code sample)
Can I use the SqlDataSource in code? First I used it to return some rows
and that worked. Then I added the arguements so that I could do paging, but
it threw and exception that I didn't set the SqlDataSourceMode. I did set
it to dataset, but I still get the same exception.
I am calling a stored procedure that returns search results. I don't want
to bind to Gridview or anything like that, I just want the dataset filled
with a specified page.
The error message is:
The SqlDataSource '' does not have paging enabled. Set the DataSource to
DataSet to enable paging.
Here's some code:
....
data = new SqlDataSource(eConnect, "dbo.Search");
data.DataSourceMode = SqlDataSourceMode.DataSet;
data.SelectParameters.Add("Search", TypeCode.String, sSearch);
data.SelectCommandType =
SqlDataSourceCommandType.StoredProcedure;
args = new DataSourceSelectArguments();
args.StartRowIndex = 1;
args.MaximumRows = 2;
IEnumerable result = data.Select(args);
if (result != null)
{
dv = (DataView)result;
dv.Table.TableName = "T";
ds = dv.Table.DataSet;
....
This is just a test, so the actual page parameters are fixed.
Is there anything special that I need to know how to do?
Thanks in advance,
Donald