asp.net| data
Binding with DataBinder.Eval does not necessarily concern the data source (Dataread or DataSet). You don't have to care about the type of data. Eval converts this data object to a string. A lot of work was done on the bottom bound, using reflective performance. It is easy to use, but it affects the performance of the data. When the dataset is bound, the DataItem is actually a datarowview (if the binding is a data reader (Dataread) it is a idatarecord. Therefore, the direct conversion to DataRowView will give a great boost to performance.
Note When using: 1. Note The case of the field name (pay special attention to). If inconsistent with the query, in some cases it can lead to slower than <%# DataBinder.Eval (Container.DataItem, field name)%>. 2. If the speed is to be further improved, the method of <%# ((System.Data.DataRowView) Container.DataItem) [0]%> can be used. But its readability is not high.
When you make a dataset as a data source
Normal (C #)
<%# ((System.Data.DataRowView) container.dataitem) ["Title"]%>
Bound Date field format string
<%# Convert.todatetime ((System.Data.DataRowView) Container.DataItem)
["Fbtime"]). ToString ("YYYY year mm month DD Day")%>
<%# DataBinder.Eval (Container, "Dataitem.fbtime", "{0:yyyy year mm month DD day}")%>
String binding exceeds specified length truncation
<%# DataBinder.Eval (Container.DataItem, "Text"). ToString (). Trim (). Length>7?
DataBinder.Eval (Container.DataItem, "Text"). ToString (). Trim (). Substring
(0,7):D atabinder.eval (Container.DataItem, "Text"). ToString (). Trim ()%>
Price grid try to 2 decimal places
<%# Convert.todecimal ((System.Data.DataRowView) container.dataitem) ["Price"]). ToString ("F2")%>
<%# DataBinder.Eval (Container, "Dataitem.price", "{0:F2}")%>
' VB.net the price after the format of the decision
<%# IIf (DataBinder.Eval (Container.DataItem, "price", "{0:f2}") = "0.00", "Negotiable", DataBinder.Eval (Container.DataItem, "Price", "{0:F2}") + "Million")%>
' VB.net routine
<%# Ctype (Container.dataitem,datarowview). Row ("Title")%>