今天做页面要用到ASP的Repeater数据注入,由于之前没用过ASP,发现填充数据有两种模式:
cs文件的代码为
dt = ds.Tables[2];
rpDistinct.DataSource = dt;
rpDistinct.DataBind();
前端的代码为
<asp:Repeater runat="server" ID="rpDistinct">
<ItemTemplate>
<div class="title">
<img src="../img/title-03_03.png" />
<h2><%#Eval("attributeName") %></h2>
</div>
<div class="content">
<p><%#Eval("attribyteValue") %></p>
</div>
</ItemTemplate>
</asp:Repeater>
attributeName attribyteValue为数据表中的列名。那么我想请问前端代码中使用的是<%#Eval("字段名")%>是否可以用<%#Container.DataItem("字段名")%>,<%#((DataRowView)Container.DataItem)["字段名"]%>或<%#((DataRowView)Container.DataItem).Rows[0]["字段名"]%>或<%#DataBinder.Eval(Container.DataItem, "字段名")%来替换呢,替换的话有什么要改动的吗?求大神指点
cs文件的代码为
dt = ds.Tables[2];
rpDistinct.DataSource = dt;
rpDistinct.DataBind();
前端的代码为
<asp:Repeater runat="server" ID="rpDistinct">
<ItemTemplate>
<div class="title">
<img src="../img/title-03_03.png" />
<h2><%#Eval("attributeName") %></h2>
</div>
<div class="content">
<p><%#Eval("attribyteValue") %></p>
</div>
</ItemTemplate>
</asp:Repeater>
attributeName attribyteValue为数据表中的列名。那么我想请问前端代码中使用的是<%#Eval("字段名")%>是否可以用<%#Container.DataItem("字段名")%>,<%#((DataRowView)Container.DataItem)["字段名"]%>或<%#((DataRowView)Container.DataItem).Rows[0]["字段名"]%>或<%#DataBinder.Eval(Container.DataItem, "字段名")%来替换呢,替换的话有什么要改动的吗?求大神指点