asp.net 2.0– use DataSourceMode properties

Source: Internet
Author: User
asp.net

The DataSourceMode property of the SqlDataSource control determines how the extracted data is maintained.

The default value for the DataSourceMode property is the dataset, which means that the result set extracted from the database is stored in a DataSet object in the server's memory, if you use SqlDataSource as the data source for controls such as the GridView, And to sort, filter, and paging in the GridView control, the SqlDataSource DataSourceMode attribute must be set to a dataset.

On the other hand, however, if the data extracted by SqlDataSource is only to be used as an option for controls such as DropDownList and ListBox, and no sorting, filtering and paging processing is required, The DataSourceMode attribute of SqlDataSource should be set to DataReader so as to reduce the consumption of resources. After all, using datasets at such times is simply overkill.

Once you set the DataSourceMode property to DataReader, the data is extracted through a IDataReader object (that is, a straightforward and read-only data pointer), and the result set will not be stored in the server's memory.

If you have a clear understanding of the characteristics and differences of the dataset model and the data command model, you should be able to know when to use the dataset and when to use DataReader.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.