我在使用转发器时非常模糊
是不是在sql的第一行显示数据?
我的数据库中的数据
userName Phone
Admin admin
roy 012345678
ken 012345678
从我的代码输出
userName:Admin
电话:admin
------------------------------------
userName:roy
电话:012345678
------------------------------------
userName:ken
电话:012345678
------------------------------------
预期输出
userName: roy
phone: 012345678
------------------------------------
userName: ken
phone: 012345678
----------------------
下面的是我的代码
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1" >
<ItemTemplate>
Course Name: <%#DataBinder.Eval(Container.DataItem, "subject" )%>
<br />
Subject Info: <%#DataBinder.Eval(Container.DataItem,"subjectIntroduction")%>
<hr />
</asp:Repeater>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT [subject], [subjectIntroduction] FROM [courseSubjectTable]">
</asp:SqlDataSource>
答案 0 :(得分:1)
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1" >
<ItemTemplate>
userName:
<%#DataBinder.Eval(Container.DataItem, "subject" ) +"<br/>"%>
phone:
<%#DataBinder.Eval(Container.DataItem,"subjectIntroduction") + "<hr/>"%>
</ItemTemplate>
</asp:Repeater>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT [subject], [subjectIntroduction] FROM [courseSubjectTable]">
</asp:SqlDataSource>
使用此选项不显示admin:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT [subject], [subjectIntroduction] FROM [courseSubjectTable] where userName <> 'Admin'">