如何使用我的GridView修复此错误
本文关键字:错误 GridView 何使用 我的 | 更新日期: 2023-09-27 18:23:58
我有下面的.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
错误表明网格必须放置在表单标记中。
<form runat="server">
//your grid here
</form>
我认为错误消息是说GridView需要嵌套在具有runat="server"
属性的<form>
标记中。
<form runat="server">
...
<GridView runat="server" ... >
...
</form>
我西班牙语说得不流利,但marca de formato
作为form tag
的翻译在我看来不太合适,这可能会使错误消息变得混乱。