Some quick notes on ASP.net and data

Data Binding

.NET 3.5 Wrox Box: Professional ASP.NET 3.5, Professional C# 2008, Professional LINQ, .NET Domain-Driven Design with C#

There are 3 different ways to do data binding within the data view. These can be set as part of the template:
  • <%# Eval(…) %> - Merely writes it out, as is. The is the default when you convert to template
  • <%# Bind(…) %> - Can be used to write it out and can do post it back in the edit scenario, allowing us to update the database
  • <%# XPath(…) %> - used with XML datasource. To supply a XPath string so that we can query the XML to get the data suing an Xpath expression.

Example:
<%# Eval(“FieldName”) %>

The <%# represent a databinding expression, the example above allows you to write out the value of a field that the database has.

Sql Data Source

A SQL data source has a datasource mode, that you can change. For readonly databases or databases that do not change that often in the asp definition change the DataSourceMode="DataReader", this will speed up the dataaccess. The reason is that, the data is streamed rather than read in chunks. You cannot use Caching and sorting in this mode though.

Comments