[英]Repeater not showing items from SQL Data Source
I need to use a Repeater to display data from an SQL Data Source object, but it's not working. 我需要使用中继器来显示来自SQL数据源对象的数据,但是它不起作用。 I tried the same with GridView and it worked fine, so everything is working except for the Repeater thing. 我在GridView上尝试了同样的方法,并且效果很好,所以除了Repeater之外,其他所有东西都可以正常工作。
The result I get is a bunch of "System.Data.DataRowView System.Data.DataRowView..." 我得到的结果是一堆“ System.Data.DataRowView System.Data.DataRowView ...”
C# code: C#代码:
protected void Page_Load(object sender, EventArgs e)
{
repeater.DataSource = SqlDataSource1;
repeater.DataBind();
}
ASP: ASP:
<asp:Repeater ID="repeater" runat="server">
<ItemTemplate>
<%# Container.DataItem %>
</ItemTemplate>
</asp:Repeater>
Thanks in advance! 提前致谢!
You need to add in your itemtemplate tag with Eval("YourColumnName") or Databinder.Eval(). 您需要使用Eval(“ YourColumnName”)或Databinder.Eval()添加itemtemplate标记。
<ItemTemplate>
<%# Eval("CodFlowElement")%>
</ItemTemplate>
or you can use like this 或者你可以这样使用
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem,"CodFlowElement")%>
</ItemTemplate>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.