Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8544751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:38:09+00:00 2026-06-11T12:38:09+00:00

I have the follow aspx page <asp:Content ID=Content2 ContentPlaceHolderID=contentConteudo runat=server> <table border=0 width=680 style=background-color:#f0f0f0

  • 0

I have the follow aspx page

<asp:Content ID="Content2" ContentPlaceHolderID="contentConteudo" runat="server">        
    <table border="0" width="680" style="background-color:#f0f0f0" id="tabelaPrincipal" runat="server">
        <tr>
            <td style="width: 180px !important;">            
                <asp:RadioButtonList ID="rbBuscas" runat="server">
                    <asp:ListItem Selected="True">Novo Curso</asp:ListItem>
                    <asp:ListItem>Buscar Lista de Presença</asp:ListItem>
                </asp:RadioButtonList>           
            </td>
            <td>
                Data: <br />
                <input id="DtBusca" type="text" />                
                <asp:Button id="btnSelecionarData" runat="server" Text="Buscar" />
            </td>
        </tr>
    </table>


    <br /><br />
    <div id="infoGrid" runat="server">
        <cc1:GridView ID="grdImoveis" CssClass="StyleGrid" Width="100%" runat="server" ShowHeader="false"
            AutoGenerateColumns="False" DataSourceID="dsGrid" BorderWidth="0px" GridLines="None"
            AllowPaging="True" EnableModelValidation="True">
            <AlternatingRowStyle BackColor="White" CssClass="EstiloDalinhaAlternativaGrid" HorizontalAlign="Center" />
            <RowStyle CssClass="EstiloDalinhaGrid" HorizontalAlign="Center" />
            <Columns>
                <asp:TemplateField HeaderText="Nome">
                    <ItemTemplate>
                        <div class="<%# Eval("Usuario_Id").ToString() %>">
                           <%# Eval("NomeCompleto").ToString() %>
                        </div>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField HeaderText="Cargo" DataField="DescricaoCargo1" />
                <asp:BoundField HeaderText="Data Cadastro" DataField="DataHora" />
                <asp:TemplateField ControlStyle-CssClass="acoes_lista_imovel" HeaderText="Curso">
                    <ItemTemplate>
                        <div class="acoes_lista_imovel">
                            <%# montaIcones(Eval("Usuario_Id").ToString())%>
                        </div>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <div>
                            <%# montaIconesDocumentacao(Eval("Usuario_Id").ToString())%>
                        </div>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </cc1:GridView>
        <asp:SqlDataSource ID="dsGrid" runat="server"></asp:SqlDataSource>
    </div>
    <span id="printContrato" class="diasRelatorio btStep ui-button ui-widget ui-state-default ui-corner-all"></span>


</asp:Content>

The problem occurs when I click in my <asp:Button>, I tryied to put the OnClick event, but still happens the error.

<asp:Button id="btnSelecionarData" runat="server" Text="Buscar" />

ERROR

Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.

CODE BEHIND

    public partial class ListaUsuarioProvisorio : System.Web.UI.Page
    {
        neticonn.Conexao c = new neticonn.Conexao();
        Utilidade.QuebraToken tk = new Utilidade.QuebraToken();
        public string icones = string.Empty;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.CarregaLista();
            }
        }

        protected void CarregaLista()
        {
            string select = string.Empty;
            select += "SELECT San_Credenciada.Apelido, San_Usuario.NomeCompleto, San_Usuario.Usuario_Id, San_Usuario.DescricaoCargo1, "
                + "CONVERT(varchar, San_Usuario.DataHora, 103) AS DataHora "
                + "FROM San_Usuario "
                + "JOIN San_Credenciada "
                + "ON San_Usuario.Credenciada_Id = San_Credenciada.Credenciada_Id "
                + "WHERE San_Usuario.Provisorio = 1 "
                + "AND San_Usuario.Excluido = 0 "
                + "GROUP BY San_Credenciada.Apelido, San_Usuario.NomeCompleto, San_Usuario.Usuario_Id, " 
                + "San_Usuario.DescricaoCargo1, San_Usuario.DataHora "
                + "ORDER BY San_Usuario.DataHora ASC ";

            dsGrid.ConnectionString = c.Con;
            dsGrid.SelectCommand = select;
            dsGrid.Dispose();

            GridViewHelper helper = new GridViewHelper(this.grdImoveis);
            helper.RegisterGroup("Apelido", true, true);            
            helper.GroupHeader += new GroupEvent(helper_GroupHeader);
            helper.ApplyGroupSort();
        }

        protected void CarregaLista(string data)
        {
            string select = string.Empty;
            select += "SELECT San_Credenciada.Apelido, San_Usuario.NomeCompleto, San_Usuario.Usuario_Id, San_Usuario.DescricaoCargo1, "
                + "CONVERT(varchar, San_Usuario.DataHora, 103) AS DataHora "
                + "FROM San_Usuario "
                + "JOIN San_Credenciada "
                + "ON San_Usuario.Credenciada_Id = San_Credenciada.Credenciada_Id "
                + "JOIN San_UsuarioCurso "
                + "ON San_Usuario.Usuario_Id = San_UsuarioCurso.Usuario_Id "
                + "WHERE San_Usuario.Provisorio = 1 "
                + "AND San_Usuario.Excluido = 0 "
                + "AND San_UsuarioCurso = " + data + " "
                + "GROUP BY San_Credenciada.Apelido, San_Usuario.NomeCompleto, San_Usuario.Usuario_Id, "
                + "San_Usuario.DescricaoCargo1, San_Usuario.DataHora "
                + "ORDER BY San_Usuario.DataHora ASC ";

            dsGrid.ConnectionString = c.Con;
            dsGrid.SelectCommand = select;
            dsGrid.Dispose();

            GridViewHelper helper = new GridViewHelper(this.grdImoveis);
            helper.RegisterGroup("Apelido", true, true);
            helper.GroupHeader += new GroupEvent(helper_GroupHeader);
            helper.ApplyGroupSort();
        }

        private void helper_GroupHeader(string groupName, object[] values, GridViewRow row)
        {
            string xCol = "#f56d01";
            string yCol = "#cbcbcb";
            Color c = System.Drawing.ColorTranslator.FromHtml(xCol);
            Color c2 = System.Drawing.ColorTranslator.FromHtml(yCol);

            if (groupName == "Apelido")
            {
                row.BackColor = c;
                row.Cells[0].Text = "<div class='AgrupamentoPrincipal'>&nbsp;&nbsp;" + Maiscula(row.Cells[0].Text) + "</div>";
                row.Cells[0].Text += "</div><tr bgcolor=#e2dcd2 class=thGrid><th scope=col height='27'>&nbsp;Nome</th><th scope=col>Cargo</th><th>Data Cadastro</th><th scope=col>Curso Básico</th><th>Documentação Imobiliária</th></tr>";             
            }
        }

        protected string Maiscula(string texto)
        {
            texto = texto.ToUpper();
            return texto;
        }

        protected string montaIcones(string id)
        {
            icones = string.Empty;            
            int Credenciada = Convert.ToInt32(tk.CarregaToken(1, Request.Cookies["token"].Value));
            icones = "<img src='../tema/default/icon/icon-cinza/check.png' onclick=\"Visibilidade('" + id + "', '" + id + "', '" + Credenciada + "')\" style='cursor:pointer;margin: 4px;text-align:center;' ID='" + id + "' />";
            return icones;
        }

        protected string montaIconesDocumentacao(string id)
        {
            icones = string.Empty;
            int Credenciada = Convert.ToInt32(tk.CarregaToken(1, Request.Cookies["token"].Value));
            icones = "<img src='../tema/default/icon/icon-cinza/documents.png' onclick=\"VisibilidadeDocumentacao('" + id + "', 'documentacao_" + id + "', '" + Credenciada + "')\" style='cursor:pointer;margin: 4px;text-align:center;' ID='documentacao_" + id + "' />";
            return icones;
        }

        public void btnSelecionarData_OnClick(object sender, EventArgs e)
        {
            if (this.rbBuscas.SelectedIndex == 1 && !this.DtBusca.Value.Equals(string.Empty))
            {
                this.CarregaLista(this.DtBusca.Value);
            }
        }
    }
}

Somebody can help me ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T12:38:10+00:00Added an answer on June 11, 2026 at 12:38 pm

    This problem typically occurs when you are creating custom controls in your code behind. I would take a look at this article, which goes into depth about the origin of the problem and how you can spot check your code for such issues:

    http://blog.typps.com/2008/01/failed-to-load-viewstate-typical.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a follow dropdown list in my aspx page: <asp:DropDownList ID=OrderPeriodStatus runat=server AutoPostBack=true
In an asp.net application, I have the follow code in the aspx page: <asp:Content
I have the follow piece of my .aspx page <div class=StatusImovelFiltros style=background-color:#f6f6f6;padding:10px;> <div class=TituloFiltros>Status
I am having an aspx page where I have added one asp.net text box
I have a DIV inside my repeater as follows: <asp:Repeater ID=topicView runat=server OnItemCommand=Delete_ItemCommand> <ItemTemplate>
I have a textbox and an image button as follows <asp:TextBox ID=myText runat=server></asp:TextBox> <asp:ImageButton
I have a ASP.NET MVC2 application with a master page. The master page renders
My web application is an Asp.Net MVC pattern. None of the .aspx pages have
I have a master page that holds the loginview content that appears on all
I have a silverlight app that uses a simple Login.aspx page. I have all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.