如何在datalist中添加emptydatatemplate [英] How do I add emptydatatemplate in datalist
本文介绍了如何在datalist中添加emptydatatemplate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< asp:DataList ID =dlContractrunat =server>
< HeaderTemplate>
< div class =row col-xs-12 col-sm-12 col-md-12 col-lg-12 pull-left label-defaultstyle =width:300px; height:50px> ;
< h3>< asp:Label ID =Label10runat =serverText =Contract DetailsStyle =text-align:center>< / asp:Label>< / H3>< / DIV>
< / HeaderTemplate>
< ItemTemplate>
< div class =row>
< div class =infobckstyle =height:40px; width:300px; border-left-color:#808080>
< div class =col-xs-9 col-sm-9 col-md-9>< asp:Label ID =Label9runat =serverText =CREATED:CssClass = dlfnt >< / ASP:标签>< / DIV>
< div class =col-xs-3 col-sm-3 col-md-3>< asp:Label ID =Label3runat =serverText ='<%# Eval(CREATED)%>'Style =font-size:large>< / asp:Label>< / div>
< div class =col-xs-3 col-sm-3 col-md-3>< asp:Label ID =lblmsgrunat =serverText =今天没有交易Style =font-size:largeVisible =false>< / asp:Label>< / div>
< / div>
< div class =infobckstyle =height:40px; width:300px; border-left-color:#808080>
< div class =col-xs-9 col-sm-9 col-md-9>< asp:Label ID =Label7runat =serverText =SCHEDULED:CssClass = dlfnt >< / ASP:标签>< / DIV>
< div class =col-xs-3 col-sm-3 col-md-3> < asp:Label ID =Label5runat =serverText ='<%#Eval(SCHEDULED)%>'Style =font-size:large>< / asp:Label> < / DIV>
< / div>< / div>
< / ItemTemplate>
< FooterTemplate>
< asp:Label ID =lblNoRecordrunat =serverText =No Record Found! Visible ='<%#bool.Parse((dlContract.Items.Count == 0).ToString())%>'>< / asp:Label>
< / FooterTemplate>
< / asp:DataList>
这里它给出了例外,因为bool未被声明或因保护而无法访问等级
我尝试过的事情:
< FooterTemplate>
< asp:Label ID =lblNoRecordrunat =serverText =No Record Found! Visible ='<%#bool.Parse((dlContract.Items.Count == 0).ToString())%>'>< / asp:Label>
< / FooterTemplate>
解决方案
它说你不能使用bool。所以,改为在类中创建一个bool属性,然后使用它。如:
可见='<%#!this.HasRecords%>'
public bool HasRecords {获取; 设置;}
...
HasRecords = dt.Rows.Count > 0
<asp:DataList ID="dlContract" runat="server"> <HeaderTemplate> <div class="row col-xs-12 col-sm-12 col-md-12 col-lg-12 pull-left label-default" style ="width:300px;height:50px"> <h3><asp:Label ID="Label10" runat="server" Text="Contract Details" Style="text-align:center"></asp:Label></h3></div> </HeaderTemplate > <ItemTemplate> <div class="row"> <div class="infobck" style="height:40px;width:300px;border-left-color:#808080"> <div class="col-xs-9 col-sm-9 col-md-9"><asp:Label ID="Label9" runat="server" Text="CREATED :" CssClass="dlfnt"></asp:Label></div> <div class="col-xs-3 col-sm-3 col-md-3"><asp:Label ID="Label3" runat="server" Text='<%#Eval("CREATED")%>' Style="font-size:large"></asp:Label></div> <div class="col-xs-3 col-sm-3 col-md-3"><asp:Label ID="lblmsg" runat="server" Text="No transaction for today" Style="font-size:large" Visible="false"></asp:Label></div> </div> <div class="infobck" style="height:40px;width:300px;border-left-color:#808080"> <div class="col-xs-9 col-sm-9 col-md-9"><asp:Label ID="Label7" runat="server" Text="SCHEDULED :" CssClass="dlfnt"></asp:Label></div> <div class ="col-xs-3 col-sm-3 col-md-3"> <asp:Label ID="Label5" runat="server" Text='<%#Eval("SCHEDULED")%>' Style="font-size:large"></asp:Label></div> </div></div> </ItemTemplate> <FooterTemplate> <asp:Label ID="lblNoRecord" runat="server" Text="No Record Found!" Visible='<%#bool.Parse((dlContract.Items.Count==0).ToString())%>' ></asp:Label> </FooterTemplate> </asp:DataList>
Here it gives exception as bool is not declared or may be inaccessible due to protection level
What I have tried:
<FooterTemplate> <asp:Label ID="lblNoRecord" runat="server" Text="No Record Found!" Visible='<%#bool.Parse((dlContract.Items.Count==0).ToString())%>' ></asp:Label> </FooterTemplate>
解决方案
It says you cannot use bool. So, instead make a bool property in the class and then use that instead. Such as:
Visible='<%# !this.HasRecords %>'
public bool HasRecords{ get;set;} ... HasRecords = dt.Rows.Count > 0
这篇关于如何在datalist中添加emptydatatemplate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文