Data Binding affects execution efficiency)

Source: Internet
Author: User

Commonly used: <% # databinder. eval (container, "dataitem. cityid") %>

However, in 2.0, only <% # eval ("dataitem. cityid") %> is allowed.

<% # Binder ("dataitem. cityid") %> used to bind controls in 2.0

The following are all versions earlier than 2.0.

Suitable for dataset, with higher efficiency than eval

<% # (Datarowview) container. dataitem) ["cityid"] %>

<% # (Datarowview) container. dataitem) [0] %>

======================================

Data Binding databinder

General Binding method <% # databinder. eval (container. dataitem, "field name") %> Use databinder. eval to bind data source (dataread or dataset ). You don't have to worry about the data type. Eval converts the data object into a string. It does a lot of work on the underlying binding and uses the reflection performance. This is because it is easy to use, but affects data performance. Let's see <% # databinder. eval (container. dataitem, "field name") %>. When dataset is bound, dataitem is actually a datarowview (if it is bound to a data reader (dataread), it is an idatarecord .) Therefore, directly converting to datarowview will greatly improve the performance.

<% # Ctype (container. dataitem, datarowview). Row ("field name") %>

* We recommend that you use <% # ctype (container. dataitem, datarowview). Row ("field name") %> to bind data. When the data volume is large, the speed can be increased by several hundred times.
Pay attention to the following two aspects during use:
1. Add <% @ import namespace = "system. Data" %>.
2. Pay attention to the Case sensitivity of field names ). If it is inconsistent with the query, it may be slower than <% # databinder. eval (container. dataitem, "field name") %> in some cases. To further increase the speed, you can use the <% # ctype (container. dataitem, datarowview). Row (0) %> method. But its readability is not high.

The above is the VB.net method.

In C #: For dataset, datatable: <@ % (datarowview) container. dataitem) ["field name"] %>
For datareader: <@ % (idatareader) container. dataitem) ["name"] %>

======================================

Conclusion: Using serial numbers to specify data columns is more efficient, and eval binding is less efficient.

Binding custom object classes:

For example, griview is bound to datasource ilist <bookinfo>,

Then its binding expression can be written

<% # (Bookinfo) (container. dataitem). bookcode %>

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.