Sunday, June 29, 2008

ASP.NET data binding essentials

<%# %> Syntax

ASP.NET introduces a new declarative syntax, <%# %>. This syntax is the basis for using data binding in an .aspx page. All data binding expressions must be contained within these characters. The following list includes examples of simple data binding from multiple sources:

• Simple property (syntax for a customer):
<%# custID %>

• Collection (syntax for an order):
<asp:listbox id="List1" datasource="'<%#">' runat="server">

• Expression (syntax for a contact):
<%# ( customer.First Name + " " + customer.LastName ) %>

• Method result (syntax for the outstanding balance):
<%# GetBalance(custID) %>

In the preceding examples, the inline <%# %> tags indicate where the information from a specific data source is to be placed in the .aspx page. The following data binding example uses a TextBox Web server control: <asp:textbox id="txt" text=="<%# custID %>" runat=server />

For more information about data binding syntax, see the following .NET Framework Software Development Kit (SDK) documentation:
Data Binding Expression Syntax


Pavithra M said...

Given so much information in it. its very useful .perfect explanation about Dot net framework.Thanks for your valuable information. dot net training in chennai velachery | dot net training institute in velachery

Mithun Mithun said...

It is really a great work and the way in which u r sharing the knowledge is excellent.
Thanks for helping me to understand basic concepts. As a beginner in Dot Net programming your post help me a lot.Thanks for your informative article.. dot net training and placement in chennai | best dot net training in chennai