使用VS 2008,我有一个中继器控件:
<asp:Repeater runat="server" ID="storesRep" DataSourceID="storeSqlDataSource"
OnItemDataBound="StoresRep_ItemDataBound">
<ItemTemplate>
<table style="padding:0px">
<tr>
<td style="width:200px"><asp:Label ID="infoLbl" runat="server">
Choose stores for upload:</asp:Label>
</td>
<td style="width:110px">
<asp:Label ID="storeLbl" runat="server" Text='<%# Bind("Name") %>'>
</asp:Label>
</td>
<td><asp:CheckBox runat="server" ID="storeCheck" /></td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
<asp:SqlDataSource ID="storeSqlDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:someConnectionString %>"
SelectCommand="SELECT [StoreId], [Name] FROM [Store] Order By [Name]">
</asp:SqlDataSource>
现在,如果数据源没有从数据库返回任何项,我想显示一个默认文本,如"No stores found".到目前为止,我主要使用GridView
,因为EmptyDataText
属性,我没有问题.