私はフォローaspx
ページを持っています
<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>
をクリックすると問題が発生し<asp:Button>
、イベントを配置しようとしましたOnClick
が、それでもエラーが発生します。
<asp:Button id="btnSelecionarData" runat="server" Text="Buscar" />
エラー
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.
コードビハインド
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'> " + Maiscula(row.Cells[0].Text) + "</div>";
row.Cells[0].Text += "</div><tr bgcolor=#e2dcd2 class=thGrid><th scope=col height='27'> 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);
}
}
}
}
誰かが私を助けることができますか?