我收到此错误
" DataSource和DataSourceID都在' DataListCity'上定义。删除一个定义。"
这是我的母版页中导致错误的代码
<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>
答案 0 :(得分:0)
如果您已编写代码,则从cs中删除绑定代码,因为您只能通过代码绑定或来自设计而不是同时绑定
从
背后的代码中删除这些行DataListCity.DataSource=somesource;
DataListCity.DataBind();