Template and data binding expression

Source: Internet
Author: User

AlmostAllAll data binding controls support templates ).

InShow dataYesUse a template to format the layout and appearance of each data item.

With the template, you canEnableUse a data binding expression to display the value of a data item.

 

Use Template

(Except for Treeview) data binding control in 2.0Templates are supported.

Repeater, datalist, and formview must use templates to display data.

Supported templates, such as gridview, detailsview, and menu, are not required.

 

The template can contain

    • Html
    • Data Binding expression
    • Other controls

Example: hyperlink list

<% @ Page Language = "  VB  " %> <! Doctype html Public   "  -// W3C // dtd xhtml 1.0 transitional // en  "   "  Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd  " > <SCRIPT runat = "  Server  " > </SCRIPT> <HTML xmlns = "  Http://www.w3.org/1999/xhtml  " > <Head runat = " Server  " > <Title> display link </title>  "  Form1  " Runat = "  Server  " > <Div> <asp: repeater id = "  Repeater1  " Runat = "  Server  " Performanceid ="  Srcmovies  " > <Itemtemplate> <asp: hyperlink id = "  Hyperlink1  " Runat = "  Server  " Navigateurl = '  <% # Eval ("ID", "details. aspx? Id = {0} ") %> '> <% # eval (" title ") %> </ASP: hyperlink> <Br/> </itemtemplate> </ASP: repeater> <asp: sqldatasource id = " Srcmovies  "  Connectionstring = "  Data Source =. \ sqlexpress; Integrated Security = true; user instance = true; attachdbfilename = | datadirectory | mydatabase. MDF  "  Selectcommand = "  Select ID, title from movies  "  Runat = "  Server  " /> </Div> </form> </body> 
<% @ Page Language = "  VB  " %> <! Doctype html Public   "  -// W3C // dtd xhtml 1.0 transitional // en  "   "  Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd  " > <SCRIPT runat = "  Server  " > </SCRIPT> <HTML xmlns = "  Http://www.w3.org/1999/xhtml  " > <Head runat = "  Server  " > <Title>  "  Form1  " Runat = "  Server  " > <Div> <asp: gridview id = " Gv1  " Performanceid = "  Srcmovies  " Runat = "  Server  " > </ASP: gridview> <asp: sqldatasource id = "  Srcmovies  "  Connectionstring = " Data Source =. \ sqlexpress; Integrated Security = true; user instance = true; attachdbfilename = | datadirectory | mydatabase. MDF  "  Selectcommand = "  Select title, Director from movies where id = @ mid  "  Runat = "  Server  " > <Selectparameters> <asp: querystringparameter name = "  Mid  " Type = "  Int32  " Querystringfield = "  ID  " /> </Selectparameters> </ASP: sqldatasource> </div> </form> </body> 

 

Use a data binding expression

Data Binding expressionRuntimeTo calculate the result.

(Used on the page) as long as the expressionIncluded in the <% # %> symbol.

Data Binding expressionWhen the databinding event of the control is triggeredTo start calculating the value.

For the [declarative data binding] event isAutomatically triggered.

For the [programmatic data binding] event inTriggered when databind method is called.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.