In ASP Web Forms solution I want to hide EmptyDataTemplate in Page_Load method? how to do this ?
This is front end:
<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>
This is back end:
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (string.IsNullOrEmpty(tbSearch.Text))
{
hideInPageLoad.Visible = false;
}
but error is this..... :
Error 1 The name 'hideInPageLoad' does not exist in the current context
Because hideInPageLoad
is inside Gridview EmptyDataTemplate, Could try out this:
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");
}
}
}
}