2012-02-08 38 views
1

解決這個錯誤,我有如下一塊我.aspx頁面中如何使用我的GridView

<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 =「服務器」。

爲什麼會出現這種錯誤?我有他runat =「服務器」在我的gridview。

錯誤堆棧

[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 
+1

runat =「server」丟失。你可以發佈完整的例外 – 2012-02-08 13:41:18

+0

按照我的錯誤堆棧 – 2012-02-08 13:43:44

回答

2

錯誤表示網格必須放置在表單標籤內。

<form runat="server"> 
    //your grid here 
</form> 
+0

工作正常。謝謝! – 2012-02-08 14:04:56

1

我認爲錯誤消息是說,你的GridView需要嵌套在<form>標籤具有runat="server"屬性中。

<form runat="server"> 
... 

    <GridView runat="server" ... > 
    ... 

</form> 

我不流利講西班牙語,但marca de formato不看我的權利爲form tag翻譯,這可能使該錯誤信息混淆。

+0

我不會說西班牙語,所以不得不要求谷歌幫助:) – 2012-02-08 13:52:15

+0

你是對的

。謝謝。 (這是葡萄牙語) – 2012-02-08 14:03:58

相關問題