2012-09-13 116 views
0

在我的第一次加載我的aspx頁面時,我填入了GridView刷新GridView數據

在我ASPX頁我處理我的單選按鈕

$("#ctl00_contentConteudo_rbBuscas_1").click(function() { 
     $.get("../Gerenciar/ListaUsuarioProvisorio.aspx?Documentacao=s&r=" + Math.random(2), {}, function (data) {     
     }); 
    }); 

click事件那麼,這股力量在我的頁面加載再次單擊我的單選按鈕時通過。

ASPX

<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:BoundField HeaderText="Nome" DataField="NomeCompleto" /> 
      <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> 
     </Columns> 
    </cc1:GridView> 
    <asp:SqlDataSource ID="dsGrid" runat="server"></asp:SqlDataSource> 
</div> 

後面的代碼

在背後說我的代碼,我PageLoad只是叫我CarregaLista方法,填補我的GridView

protected void CarregaLista() 
     {    
       string documentacao = Request.QueryString["Documentacao"].ToString(); 

       if (documentacao.Equals("s")) 
       { 
        string select = string.Empty; 
        select += "SELECT top 10 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.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.DataBind(); 
        grdImoveis.DataBind(); 
        dsGrid.Dispose(); 
       } 
      } 
} 

具有更新PAN EL

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" > 
    <ContentTemplate> 
       <asp:RadioButton ID="RadioButton2" runat="server" Text="Curso Básico Netimóveis" /> 
       <asp:RadioButton ID="RadioButton1" runat="server" Text="Buscar Lista de Presença" /> 
       <asp:RadioButton ID="rdBuscas" runat="server" OnCheckedChanged="Click" Text="Curso Documentação Imobiliária" /> 
     <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:BoundField HeaderText="Nome" DataField="NomeCompleto" /> 
       <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> 
      </Columns> 
     </cc1:GridView> 

     <asp:SqlDataSource ID="dsGrid" runat="server"></asp:SqlDataSource> 
     </ContentTemplate> 
     <Triggers> 
      <asp:AsyncPostBackTrigger ControlID="rdBuscas" /> 
     </Triggers>   
     </asp:UpdatePanel> 

我的問題是,我GridView不同意這種查詢刷新。

我該如何解決這個問題?

+0

是你讓打電話給你頁面加載?爲什麼不直接使用你的點擊事件的回發,因爲你正在服務器端完成你所有的代碼。 –

+0

但是,我怎樣才能點擊我的單選按鈕,並再次打電話給我的頁面加載? –

回答

1

您可以使用Ajax Tretament - 基於UpdatePanelTriggersUpdateMode="Condition"

您可以使用此代碼(調整您的觸發你的單選按鈕的GridView和編號)

<asp:ScriptManager ID="ScriptManager1" runat="server" > 
</asp:ScriptManager> 

<asp:UpdatePanel ID="UpdatePanel1" runat="server" ModeUpdate="Conditional"> 
    <ContentTemplate> 

     <asp:GridView ID="GridView1" runat="server"> 
      <Columns> 
        ...... 
      </Columns> 
     </asp:GridView> 


     <asp:RadioButton ...../> 

    </ContentTemplate> 


    <Triggers> 
      <asp:AsyncPostBackTrigger ControlID="YourRadioButtonId" EventName="Click" /> 
    </Triggers> 
</asp:UpdatePanel> 
+0

我正在嘗試執行此操作 –

+0

Ok lucas i'am here if you need –

+0

我的Trigger的'EventName'是對我的RadioButton中存在的任何事件的引用嗎?我的Radiobutton中的事件必須調用Click? –