How can I hide a repeater in ASP.NET C# if the DataSource contains no items?

前端 未结 9 1912
小鲜肉
小鲜肉 2021-01-02 17:29

I have an ASP.NET page that uses a repeater nested within another repeater to generate a listing of data. It\'s to the effect of the following:



        
9条回答
  •  执念已碎
    2021-01-02 18:05

    use this:

    protected void Repeater1_PreRender(object sender, EventArgs e)
    {
        if (Repeater1.Items.Count < 1)
        {
            container.Visible = false;
        }
    }
    

提交回复
热议问题