none
Sorting GridView RRS feed

  • Pergunta

  • Olá, boa tarde

    Estou com um problema para efetuar o Onsorting de um gridview. Está funcionando, sendo que não dispara o evento.

    Segue abaixo meu codigo e html.

    protected void GridAtendimento_Sorting(object sender, GridViewSortEventArgs e)
        {

            if (e.SortExpression + " ASC" == ViewState["Sort"] as string)
            {
                ViewState["Sort"] = e.SortExpression + " DESC";
                e.SortDirection = SortDirection.Descending;
            }
            else
            {
                ViewState["Sort"] = e.SortExpression + " ASC";
                e.SortDirection = SortDirection.Ascending;
            }

            GridBind();

            if (ViewState["Sort"] != null)
            {
                DataSet dataSet = GridAtendimento.DataSource as DataSet;
                DataView dataView = dataSet.Tables[0].DefaultView;
                dataView.Sort = ViewState["Sort"] as string;
                GridAtendimento.DataSource = dataView;
                GridAtendimento.DataBind();
            }
        }



    <%@ Page Title="" Language="C#" MasterPageFile="~/LayOut.
    Master" AutoEventWireup="true"
        Inherits="obras_orgao_PainelConsultaAtendimento" CodeBehind="PainelConsultaAtendimento.aspx.cs" %>

    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
        <link href="../css/medicao.css" rel="stylesheet" type="text/css" />
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentBody" runat="Server">
        <div class="module-box grid_16">
            <h2 class="title show_hide">
                Painel de Consulta de Solicitação <span style="text-transform: lowercase;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    Legenda:
                    <img src="../images/situcao5_branco.gif" width="15px" style="background-color: White;"
                        alt="" />
                    Ativo |
                    <img src="../images/situcao3_amarelo.gif" width="15px" style="background-color: White;"
                        alt="" />
                    Vence hoje |
                    <img src="../images/situcao4_vermelhoClaro.gif" width="15px" style="background-color: White;"
                        alt="" />
                    Atrasado |
                    <img src="../images/icons/check.png" alt="" />
                    Ok |
                    <img src="../images/icons/check_vermelho.png" alt="" />
                    Ok com atraso |
                    <img src="../images/icons/arrow_medium_left.png" alt="" />
                    Devolveu | </span>
            </h2>
            <div class="textbox margin">
                <asp:Label ID="lblMsg" runat="server" Text="" EnableViewState="false"></asp:Label>
                <asp:UpdateProgress ID="UpdateProgress1" runat="server">
                    <ProgressTemplate>
                        <img alt="carregando..." src="../../images/loading.gif" />
                    </ProgressTemplate>
                </asp:UpdateProgress>
                <asp:GridView ID="GridAtendimento" Width="100%" CellPadding="4" ForeColor="#333333"
                    OnRowDataBound="GridAtendimento_RowDataBound" UseAccessibleHeader="true" CssClass="datatable pages-table tablesorter"
                    GridLines="Both" AllowSorting="True" OnSorting="GridAtendimento_Sorting" AutoGenerateColumns="false"
                    runat="server"
                    EmptyDataText="Nenhuma Solicitação pendente de resposta encontrado">
                    <Columns>
                        <asp:BoundField DataField="OB41_CD_CONTROLE_ATENDIMENTO" HeaderText="Nº" ReadOnly="true"
                            SortExpression="OB41_CD_CONTROLE_ATENDIMENTO" />
                        <asp:TemplateField HeaderStyle-HorizontalAlign="Left" HeaderText="ORGÃO" SortExpression="NM_SIGLA">
                            <ItemTemplate>
                                <asp:HyperLink ID="hlnkAtendimento" runat="server" Font-Size="12px"></asp:HyperLink>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderStyle-HorizontalAlign="Left" HeaderText="Número/Complemento"
                            SortExpression="NU_DOCUMENTO">
                            <ItemTemplate>
                                <asp:Label ID="lblNU_DOCUMENTO" runat="server" Font-Size="12px"></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderStyle-HorizontalAlign="Left" HeaderText="Assunto" SortExpression="NM_ASSUNTO"
                            ItemStyle-Width="300px">
                            <ItemTemplate>
                                <div style="width: 250px;">
                                    <asp:Label ID="lblAssunto" runat="server" Font-Size="12px" CssClass="quebrapalavra"></asp:Label>
                                </div>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <%--4asp:BoundField DataField="DT_PRAZO_INTERNO" HeaderText="Prazo" DataFormatString="{0:dd/MM/yy}" ItemStyle-HorizontalAlign="Center" SortExpression="DT_PRAZO_INTERNO" />
                        --%>
                        <asp:TemplateField HeaderStyle-HorizontalAlign="Center" HeaderText="Prazo" SortExpression="DT_PRAZO_INTERNO">
                            <ItemTemplate>
                                <center>
                                    <asp:Label ID="lblPrazo" runat="server" Font-Size="12px"></asp:Label>
                                </center>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <%--5--%><asp:BoundField DataField="DT_LIMITE" HeaderText="Data Limite" DataFormatString="{0:dd/MM/yy}"
                            ItemStyle-HorizontalAlign="Center" SortExpression="DT_LIMITE" />
                        <asp:TemplateField SortExpression="FL_CADASTRO" ItemStyle-Width="50px" HeaderText="GSE">
                            <ItemTemplate>
                                <center>
                                    <asp:Label ID="lblGSE" runat="server" Style="font-size: 12px;"></asp:Label><br />
                                    <asp:Image ID="imgGSE" runat="server" />
                                </center>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField SortExpression="FL_RESP_TEC" ItemStyle-Width="50px" ItemStyle-HorizontalAlign="Center"
                            HeaderText="SUBSEC">
                            <ItemTemplate>
                                <center>
                                    <asp:Label ID="lblRespTec" runat="server" Style="font-size: 12px;"></asp:Label><br />
                                    <asp:Image ID="imgRespTec" runat="server" />
                                </center>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField SortExpression="FL_JURIDICO" ItemStyle-Width="50px" HeaderText="ASJUR">
                            <ItemTemplate>
                                <center>
                                    <asp:Label ID="lblJuridico" runat="server" Style="font-size: 12px;"></asp:Label><br />
                                    <asp:Image ID="imgJuridico" runat="server" />
                                </center>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField SortExpression="FL_APROVADO" ItemStyle-Width="50px" HeaderText="GSE-J">
                            <ItemTemplate>
                                <center>
                                    <asp:Label ID="lblAprovacao" runat="server" Style="font-size: 12px;"></asp:Label><br />
                                    <asp:Image ID="imgAprovacao" runat="server" />
                                </center>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField SortExpression="FL_APROVADO_ORDENADOR" ItemStyle-Width="50px"
                            HeaderText="AUT">
                            <ItemTemplate>
                                <center>
                                    <asp:Label ID="lblAprovacaoOrdenador" runat="server" Style="font-size: 12px;"></asp:Label><br />
                                    <asp:Image ID="imgAprovacaoOrdenador" runat="server" />
                                </center>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField SortExpression="FL_IMPRIMIR" ItemStyle-Width="50px" HeaderStyle-HorizontalAlign="Center"
                            HeaderText="IMP">
                            <ItemTemplate>
                                <center>
                                    <asp:Label ID="lblImprimir" runat="server" Style="font-size: 12px;"></asp:Label><br />
                                    <asp:Image ID="imgImprimir" runat="server" />
                                </center>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField SortExpression="FL_FINALIZADO" ItemStyle-Width="50px" HeaderStyle-HorizontalAlign="Center"
                            HeaderText="OFICIO">
                            <ItemTemplate>
                                <center>
                                    <asp:Label ID="lblOficio" runat="server" Style="font-size: 12px;"></asp:Label><br />
                                    <asp:Image ID="imgOficio" runat="server" />
                                </center>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField SortExpression="FL_ANEXO_PROTOCOLO" ItemStyle-Width="50px" HeaderStyle-HorizontalAlign="Center"
                            HeaderText="Prot">
                            <ItemTemplate>
                                <center>
                                    <asp:Label ID="lblProtocolo" runat="server" Style="font-size: 12px;"></asp:Label><br />
                                    <asp:Image ID="imgProtocolo" runat="server" />
                                </center>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <RowStyle CssClass="RowGrid" />
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                    <EditRowStyle BackColor="#CCCCCC" />
                    <AlternatingRowStyle CssClass="AlternatingRowGrid" />
                </asp:GridView>
                <p>
                </p>
            </div>
        </div>
    </asp:Content>
    <asp:Content ID="Content3" ContentPlaceHolderID="ContentScripts" runat="server">
        <script language="javascript" type="text/jscript">
            self.setInterval(function () { clock() }, 1000 * 60 * 10);
            function clock() {
                window.location.reload();
            }
        </script>
    </asp:Content>


    Elton Araujo

    quarta-feira, 22 de agosto de 2012 20:46

Todas as Respostas

  • Você colocou um breakpoint no começo do evento de OnSorting e a execução não parou? Não entendi quando vocÊ falou: "está funcionando mas não dispara o evento", significa que está fazendo a ordenação mas você não consegue fazer o passo-a-passo dentro do método?

    Rodrigo Reis Ferreira
    Microsoft Certified

    quinta-feira, 23 de agosto de 2012 11:01
  • vi tb que sua grid está dentro de um updatePanel, como vc está carregando sua grid?

    Não esqueça de usar o componente </> na barra para posta seu código. Microsoft MCPD,MCTS,MCC

    quinta-feira, 23 de agosto de 2012 11:48
    Moderador
  • Ele faz a ordenação, mas qnd coloco um breakpoint ele não para, exatamente da maneira que vc mencionou. Gostaria de saber o pq  dele não está entrando no método.

    Elton Araujo

    quinta-feira, 23 de agosto de 2012 12:14
  • Não tem updatepanel nesse código...

    Elton Araujo

    quinta-feira, 23 de agosto de 2012 12:17