ASP.NET SqlDataSource cached collection
Is it possible to programmatically access items in sqldatasource once they are loaded? Context: sqldatasource is binded to list of checkboxes. When submitted, I have id of selected item, but I also need other information. So if I could acces loaded items in SqlDataSource that would suffice.
i know this is not very cle开发者_Go百科ar, I'm new to asp.net and it's so counter-intuituve.
As long as the sqlDataSource has been setup to Cache the data (DataSourceMode="DataSet" EnableCaching="True"
) (See Caching Data with the SqlDataSource Control) then you can select cached items using the sqlDataSource in code like so:
DataView dataView = (DataView)sqlDataSource.Select(new DataSourceSelectArguments());
DataTable dataTable = dataView.ToTable();
The DataSourceSelectArguments class provides a means to specify the SortExpression amongst other things.
Hope this helps.
精彩评论