0
I have the following scenario in which I have a Gridview but when I want to order disbelief it is not ordering.
goes below:
protected void gvdNomeClientes_Sorting(object sender, GridViewSortEventArgs e)
{
switch (e.SortExpression)
{
case "nome":
if (e.SortDirection == SortDirection.Ascending)
{
gvdNomeClientes.DataSource = lista.OrderBy(x => x.nome).ToList();
gvdNomeClientes.DataBind();
}
else
{
gvdNomeClientes.DataSource = lista.OrderByDescending(x => x.nome).ToList();
gvdNomeClientes.DataBind();
}
break;
}
}
follows the grid:
<asp:GridView runat="server"
ID="gvdClientes"
AllowPaging="true"
EmptyDataText="Nenhum registro foi inserido..."
AutoGenerateColumns="false"
OnRowCommand="gvdClientes_RowCommand"
AllowSorting="true"
OnSorting="gvdClientes_Sorting">
<Columns>
<asp:BoundField SortExpression="nome" DataField="_nomeCliente" HeaderText="Nome" HtmlEncode="False" FooterText="">
<ItemStyle BorderStyle="Solid" BorderWidth="2px" HorizontalAlign="Center" VerticalAlign="Middle"/>
</asp:BoundField>
<asp:BoundField SortExpression="cidade" DataField="_cidade" HeaderText="Cidade" HtmlEncode="False" FooterText="">
<ItemStyle BorderStyle="Solid" BorderWidth="2px" HorizontalAlign="Center" VerticalAlign="Middle"/>
</asp:BoundField>
</Columns>
</asp:GridView>
Don’t you think that "doesn’t work" is a little too generic to describe something that helps people help you? Put more details than this means, what happens, what your expectation, what you have tried alternatively.
– Maniero
thanks for the signage, I wrote fast rs, what happens is the following he orders crescently, but the decreasing t t working. I didn’t try to do it any other way...
– Tomaz Neto