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 %>