我有我的.aspx页面的跟随部分
<div class="StatusImovelFiltros" style="background-color:#f6f6f6;padding:10px;">
<div class="TituloFiltros">Status do Imóvel</div>
<%= RetornaFiltros() %>
</div>
<asp:Panel ID="pnlTabela" runat="server" Visible="false">
<div class="infoGridsemAba">
<div class='AgrupamentoPrincipal' style="background-color:#831611;padding:3px;">
Imóveis com Proposta</div>
<div class='AgrupamentoSecundario' style="background-color:#ffc274;padding:3px;">
Abaixo listando seus imóveis com proposta</div>
<asp:GridView ID="grdImoveis" CssClass="StyleGrid" Width="100%" runat="server" AutoGenerateColumns="false" DataSourceID="dsGrid" BorderWidth="0" GridLines="None">
<AlternatingRowStyle BackColor="White" CssClass="EstiloDalinhaAlternativaGrid" HorizontalAlign="Center"/>
<RowStyle CssClass="EstiloDalinhaGrid" HorizontalAlign="Center" />
<HeaderStyle BackColor="#e2dcd2" ForeColor="#000" CssClass="thGrid" Height="20" />
<Columns>
<asp:BoundField HeaderText="Código" DataField="Imovel_Id" />
<asp:BoundField HeaderText="Tipo" DataField="TipoDsc1" />
<asp:BoundField HeaderText="(L/V)" DataField="TransacaoSigla" />
<asp:TemplateField HeaderText="Endereco">
<ItemTemplate>
<%# Eval("Descricao") %> <%# Eval("Logradouro") %>, <%# Eval("Numero") %> - <%# Eval("Expr1") %> <%# Eval("Complemento") %>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="Propostas Ativas" DataField="NumeroProposta" />
</Columns>
</asp:GridView>
</div>
<asp:SqlDataSource ID="dsGrid" runat="server" OnSelected="ds_Selected"></asp:SqlDataSource>
</asp:Panel>
我放<%= RetornaFiltros() %>
的行发生错误。错误说我的GridView需要一个Runat =“server”。
为什么会出现这种错误?我的网格视图中有runat =“server”。
错误堆栈
[HttpException (0x80004005): Controle 'grdImoveis' do tipo 'GridView' deve ser inserido em uma marca de formato com runat=server.]
System.Web.UI.Page.VerifyRenderingInServerForm(Control control) +8704611
System.Web.UI.WebControls.GridView.Render(HtmlTextWriter writer, Boolean renderPanel) +40
System.Web.UI.WebControls.GridView.Render(HtmlTextWriter writer) +33
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +32
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer) +10
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +32
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
System.Web.UI.Page.Render(HtmlTextWriter writer) +29
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1266
答案 0 :(得分:2)
错误表示网格必须放在表单标记内。
<form runat="server">
//your grid here
</form>
答案 1 :(得分:1)
我认为错误消息是您的GridView需要嵌套在具有<form>
属性的runat="server"
标记内。
<form runat="server">
...
<GridView runat="server" ... >
...
</form>
我不能流利地说西班牙语,但marca de formato
并不适合作为form tag
的翻译,这可能会使错误信息混乱。