ASP.NET Repeater不会显示数据
我有一个 ASP.Net Repeater,我想用它来显示数据集中的 From 和 Text,并且我想以编程方式添加它。我拥有数据集中的所有数据,可以使用它,并且我已经在加载时验证了数据行的正确数量,因此数据是它们的,只是没有显示。我错过了什么?
Dim data As New Data
Dim ds As New DataSet
ds = data.LOADALL()
Dim drMsg() As DataRow = ds.Tables("MESSAGESYSTEM").Select("TOID='101'")
repeatMessages.DatagSource = drMsg
现在在 html 方面,我有:
<asp:Repeater ID="repeatMessages" runat="server" >
<HeaderTemplate>
<table>
<tr>
<th>From</th>
<th>Sublect</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td bgcolor="#CCFFCC">
<asp:Label runat="server" ID="Label1" text='<%# Eval("FROMID") %>' />
</td>
<td bgcolor="#CCFFCC">
<asp:Label runat="server" ID="Label2" text='<%# Eval("MESSAGETEXT") %>' />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
如何修复此代码以显示消息表中的数据?
I have an ASP.Net Repeater I want to use to show From and Text from a dataset and I want to add it programmically. I have all the data in a dataset and can use that and I have verified the correct number for datarows when it loads so the data is their it is just not showing. What have I missed?.
Dim data As New Data
Dim ds As New DataSet
ds = data.LOADALL()
Dim drMsg() As DataRow = ds.Tables("MESSAGESYSTEM").Select("TOID='101'")
repeatMessages.DatagSource = drMsg
Now on the html side I have:
<asp:Repeater ID="repeatMessages" runat="server" >
<HeaderTemplate>
<table>
<tr>
<th>From</th>
<th>Sublect</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td bgcolor="#CCFFCC">
<asp:Label runat="server" ID="Label1" text='<%# Eval("FROMID") %>' />
</td>
<td bgcolor="#CCFFCC">
<asp:Label runat="server" ID="Label2" text='<%# Eval("MESSAGETEXT") %>' />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
How can I fix this code to show the data in the Message table?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试调用
repeatMessages.DataBind()
。您所做的只是分配源,但没有告诉程序对数据执行某些操作。Try calling
repeatMessages.DataBind()
. All you are doing is assigning the source but you haven't told the program to do something with the data.