Search This Blog

Friday, July 24, 2015

Web Development Fundamentals:- Bind Controls to data By using Data-Binding Syntax

Web Development Fundamentals:-

Bind Controls to data By using Data-Binding Syntax:-

Data-Binding Syntax:-
Data-binding expressions are contained within <%# and %> delimiters and use the Eval and Bind functions.

The Eval function is used to define one-way (read-only) binding.
— Takes the name of a data field and returns a string containing the value of that field from the current record in the data source.
— Can supply an optional second parameter to specify a format for the returned string.
— The string format parameter uses the syntax defined for the Format method of the String class.

*The Bind function is used for two-way (updatable) binding.

*The Bind method is typically used with input controls such as the Textbox control rendered by a      GridView row in edit mode.
— When the data-bound control creates these input controls as part of its own rendering, it can extract the input values

* Code Sample:-

<asp:TextBox ID="EditLastNameTextBox" RunAt="Server“ Text='<%# Bind("LastName") %>'  />

Lesson Review:-
Explain  the process of data binding and how it is used in Web development.

@adsbygoogle