Panel can’t give a Visible=true on it

Asked

Viewed 438 times

1

I have a panel and inside it a Repeater with a table. This panel is inside a user control. I use this UC in several situations. I created a method called AplicarCaracteristicas, Depending on the caller, it will or will not show some controls. This works very well. There was a need for me to create another Repeater inside it. So I created a Panel and inside it I put the Repeater. In the method AplicarCaracteristicas, i then gave a Visible = true and in break I will see the value and is false and not true. Below my Panel and my method AplicarCaracteristicas. I need it to be shown only in Used Goods. The panel is called pnlGrupoCota.

<asp:Panel ID="pnlGrupoCota" runat="server" Visible="true">
            <asp:Repeater ID="rptGrupoCota" runat="server">
                <HeaderTemplate>
                <table border="0" cellpadding="0" cellspacing="0">
                    <thead>
                        <tr>
                            <th>Grupo/Cota</th>
                            <th>Crédito Disponível</th>
                            <th>Crédito Pendente</th>
                            <th>Crédito Associado</th>
                        </tr>
                    </thead>
                    <tbody>
                </HeaderTemplate>

                <ItemTemplate>
                    <tr>

                        <td><asp:Label ID="lblAnoMod" runat="server" Text="Testando 1"/></td>
                        <td><asp:Label ID="lblAnoFab" runat="server" Text="Testando 1" /></td>
                        <td><asp:Label ID="lblValorPedido" runat="server" Text="Testando 1" /></td>
                        <td><asp:Label ID="lblAlienado" runat="server" Text="Testando 1" /></td>

                    </tr>
            </ItemTemplate>

            <FooterTemplate>
                </tbody>
            </table>
            </FooterTemplate>

            </asp:Repeater>
        </asp:Panel>

My method

public void AplicarCaracteristicas()
        {
            //Declarações



            try
            {
                //Instâncias e Inicializações


                //Desenvolvimento
                switch (hdfConfiguracaoWUC.Value)
                {
                    case "1":

                        //Label do Formulário
                        lblNomeFormulario.Text  = "Bens Novos";

                        //Mostra Campos 
                        pnlFornecedor.Visible   = true;

                        //Esconder Campos não utilizados
                        cmbCdUFOrigem.Visible   = false;//Combo da UF de Origem
                        lblIcNovo.Visible       = false;//Label Veiculo Novo
                        rblIcNovo.Visible       = false;//Indicador de Veiculo Novo
                        lblUfOrigem.Visible     = false;//Label da UF de Origem

                        pnlGrupoCota.Visible = false;

                        //Esconder Botões não utilizados

                        break;

                    case "2":

                        //Label do Formulário
                        lblNomeFormulario.Text  = "Bens Usados";

                        //Mostra Campos 
                        pnlFornecedor.Visible   = true;
                        lblIcNovo.Visible       = true;//Label Veiculo Novo
                        rblIcNovo.Visible       = true;//Indicador de Veiculo Novo
                        lblUfOrigem.Visible     = true;//Label da UF de Origem
                        cmbCdUFOrigem.Visible   = true;//Combo da UF de Origem

                        //Mostra o grid de Grupo e Cota
                        pnlGrupoCota.Visible = true;


                        //Esconder Campos não utilizados

                        //Esconder Botões não utilizados

                        break;

                    case "3":

                        //Label do Formulário
                        lblNomeFormulario.Text  = "Confissão de Dívida";

                        //Mostra Campos 
                        lblIcNovo.Visible       = true;//Label Veiculo Novo
                        rblIcNovo.Visible       = true;//Indicador de Veiculo Novo
                        lblUfOrigem.Visible     = true;//Label da UF de Origem
                        cmbCdUFOrigem.Visible   = true;//Combo da UF de Origem

                        //Esconder Campos não utilizados
                        pnlFornecedor.Visible   = false;

                        pnlGrupoCota.Visible = false;


                        //Esconder Botões não utilizados

                        break;
                }

            }
            catch
            {
                throw;
            }
        }
  • Just to add, I made the panel true for all and even then it is not displayed.

  • In debug enter the case "2": and does not display? The panel is rendered in the page code normally?

  • you’d better associate the style.display property with it since there was a bug when changing the property!

  • Yes, you are in case 2. But I cannot assign true to the panel.

  • Interesting that in design I can visualize the grid

1 answer

0

Apply true Visible to page load

if(!Page.IsPostback)
{
   pnlGrupoCota.Visible = true;
}
  • I already know what it could be. In the page load it would not be possible, because otherwise it would be visible to everyone and it can only be visible inside the Used Panel. I think Repeater’s Datasource is missing. It even goes through Visible=true, but without Repeater data nothing will show and the Repeater, from what I understand, does not become visible in Runtime with fixed data, at least that’s what I was told in the OS.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.