ASP.NET - 如何在 PageLoad() 中隐藏 gridview EmptyDataTemplate

ASP.NET - How to hide gridview EmptyDataTemplate in PageLoad()

在 ASP Web 表单解决方案中 我想在 Page_Load 方法中隐藏 EmptyDataTemplate?怎么做?

这是前端:

   <EmptyDataTemplate>
                <div id="hideInPageLoad" class="row" runat="server">
                    <div class="col-md-12">
                        <div class="mt16 white p16 text-center">
                            <%# LoadResource("SHGHSearchInFund_NoResultsFound") %>
                        </div>
                    </div>
                </div>
   </EmptyDataTemplate>

这是后端:

  protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (string.IsNullOrEmpty(tbSearch.Text))
            {
                hideInPageLoad.Visible = false;
            }

但错误是这样的......:[=​​14=]

Error 1 The name 'hideInPageLoad' does not exist in the current context

因为 hideInPageLoad 在 Gridview EmptyDataTemplate 中,可以试试这个:

 protected void Page_Load(object sender, EventArgs e)
        {
         if(!IsPostBack){
            try
            {
                if (string.IsNullOrEmpty(tbSearch.Text))
                {
                    HtmlGenericControl Emptydiv=(HtmlGenericControl)gvAcheologyMonuments.Controls[0].Controls[0].FindControl("hideInPageLoad") ;
                    Emptydiv.Style.Add("Display", "none");
                }
        }
      }
    }