Data Binding Technology-how to use the databinder. eval () method for data binding

Source: Internet
Author: User

<% @ import namespace = "system. data "%>
<% @ import namespace =" system. data. sqlclient "%>

Void page_load (Object semder, eventargs E)
// Create a database connection string and sqldataadapter object
String connstr = system. configuration. configurationsettings. etettings ["connectionsqlserver_pubs"];
Sqlconnection myconnection = new sqlconnection (connstr );
Sqldataadapter mycommand = new sqldataadapter ("select * from titles", myconnection );
// Generate a DataSet object and fill in data
Dataset DS = new dataset ();
Mycommand. Fill (DS, "titles ");
// Bind the Repeater control to data
Myrepeater. datasource = Ds. Tables ["titles"]. defaultview;
Myrepeater. databind ();

<Body topmargin = "0" leftmargin = "0" marginwidth = "0" marginheight = "0">
<Asp: repeater id = "myrepeater" runat = "server">
<Table width = "100%" style = "Font: 8pt verdana">
<Tr style = "background-color: dfa894">
<TH> title </Th>
<TH> title ID </Th>
<TH> type </Th>
<TH> publisher id </Th>
<TH> price </Th>
<Tr style = "background-color: ffecd8">
<% # Databinder. eval (container. dataitem, "title") %>
<% # Databinder. eval (container. dataitem, "title_id") %>
<% # Databinder. eval (container. dataitem, "type") %>
<% # Databinder. eval (container. dataitem, "pub_id") %>
<% # Databinder. eval (container. dataitem, "price", "$ {0}") %>
</ASP: repeater>

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: 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.