【发布时间】:2015-04-02 03:21:30
【问题描述】:
我收到这个错误
“DataSource 和 DataSourceID 都在 'DataListCity' 上定义。删除一个定义。”
这是我的 Masterpage 中导致错误的代码
<asp:DataList ID="DataListCity" runat="server" Width="100%"
onitemcommand="DataListCity_ItemCommand" CellPadding="4"
ForeColor="#333333" DataSourceID="SqlDataSource1">
<ItemTemplate>
CityId:
<asp:Label ID="CityIdLabel" runat="server" Text='<%# Eval("CityId") %/>
<br />
CityName:
<asp:Label ID="CityNameLabel" runat="server" Text='<%# Eval("CityName")%>' />
<br />
<br />
</ItemTemplate>
</asp:DataList>
<asp:SqlDataSource
ConnectionString="<%$ ConnectionStrings:HotelConnString %>"
ID="SqlDataSource1" runat="server"
SelectCommand="SELECT [CityId], [CityName], [Description] FROM [Categories]">
</asp:SqlDataSource>
【问题讨论】:
-
你是否也在后面的代码中添加了这个?