感谢伤害你的人,因为他磨练你的意志。感谢欺骗你的人,因为他增进你的见识。
感谢鞭打你的人,因为他消除你的业障。感谢遗弃你的人,因为他教导你应自立。
感谢绊倒你的人,因为他强化你的力量。感谢呵责你的人,因为他助长你的定慧。
感谢所有使你坚定成就的人。
30: <asp:datagrid id="dgAuthors" runat="server" AutoGenerateColumns="False">
32: <Columns>
33: <asp:BoundColumn DataField="au_fname" HeaderText="First " />
34: <asp:BoundColumn DataField="au_lname" HeaderText="Last " />
35: <asp:BoundColumn DataField="phone" HeaderText="Phone #" />
36: </Columns>
37: </asp:datagrid>
To display a value from the DataSource
<asp:datalist id="dlAuthors" runat="server">
<ItemTemplate>
<b><%# DataBinder.Eval(Container.DataItem, "au_lname") %>,
<%# DataBinder.Eval(Container.DataItem, "au_fname") %></b>
</ItemTemplate>
</asp:datalist>
<html>
<head>
<asp:repeater id="rptAuthors" runat="server">
<HeaderTemplate>
<ol>
</HeaderTemplate>
<ItemTemplate>
<li>
<b><%# DataBinder.Eval(Container.DataItem, "au_lname") %>, <%# DataBinder.Eval(Container.DataItem, "au_fname") %></b>
</li>
</ItemTemplate>
<FooterTemplate>
</ol>
</FooterTemplate>
</asp:repeater>
</head>
<body>
</body>
</html>
感谢鞭打你的人,因为他消除你的业障。感谢遗弃你的人,因为他教导你应自立。
感谢绊倒你的人,因为他强化你的力量。感谢呵责你的人,因为他助长你的定慧。
感谢所有使你坚定成就的人。
To display a value from the DataSource
To grab a value from the DataSource, we use the DataBinder.Eval() method, which takes two parameters: an object and a string. In our examples, we'll be using Container.DataItem as the object, which is, in essence, the current row of the DataSource that's being enumerated. For the string parameter, specify the name of the column you want to have displayed. Hence, in order to output the value of the au_fname column using data-binding syntax in a template, one would use
<%# DataBinder.Eval(Container.DataItem, "au_fname") %>
<b><%# DataBinder.Eval(Container.DataItem, "au_lname") %>,
<%# DataBinder.Eval(Container.DataItem, "au_fname") %></b>
</ItemTemplate>
repeater

浙公网安备 33010602011771号