What I am trying to do is on page load display either of two controls based on how many items are in a datalist.
For instance, if the datalist only contains 1 item I want it to display
Literal1.Visible = true;
If there is more than 1 item in the datalist, then show
LiteralMulti.Visible 开发者_高级运维= true;
Anyone know how to do this?
Use can simple do that in Page_Load method :
if(DataListName.Items.Count > 1)
{
    Literalmulti.Visible = true;
} 
else
{
    Literalsingle.Visible = true;
}
Check the Count of the Items property.
Literal1.Visible = myDataList.Items.Count == 1;
LiteralMulti.Visible = myDataList.Items.Count > 1;
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论