Results 1 to 4 of 4

Thread: [Resolved] GridView Sorting Problems

Threaded View

  1. #1

    Thread Starter
    Fanatic Member snufse's Avatar
    Join Date
    Jul 2004
    Location
    Jupiter, FL
    Posts
    912

    [Resolved] GridView Sorting Problems

    I have a GridView where I am using BoundFields. When I click sorting on a bound data field, it gives me error:

    An unhandled exception of type 'System.StackOverflowException' occurred in System.Web.dll. Make sure you do not have an infinite loop.

    Code:
    Protected Sub GridView1_Sorting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSortEventArgs)
    
            Dim expression As String = e.SortExpression
            Dim direction As SortDirection = SortDirection.AscendingOrder
    
            GridView1.Sort(expression, direction)
            GridView1.DataSource = mySqlDataSet
            GridView1.DataBind()
    
    End Sub

    Code:
    <asp:GridView ID="GridView1" runat="server" Height="505px" Style="z-index: 10; left: -7px;
                position: absolute; top: 85px; border-right: gray thin solid; border-top: gray thin solid; border-left: gray thin solid; border-bottom: gray thin solid;" Width="902px" AllowPaging="True" AllowSorting="True" Font-Size="Small" PageSize="15" AutoGenerateColumns="False" CellSpacing="2" HorizontalAlign="Left" BorderColor="LightGray" BorderStyle="None" 
                onSorting="GridView1_Sorting" onrowcommand="GridView1_RowCommand">
                <PagerSettings PageButtonCount="15" />
                <RowStyle Height="6px" />
                <HeaderStyle BackColor="#FFE0C0" Height="6px" HorizontalAlign="Left" VerticalAlign="Middle" />
                <AlternatingRowStyle BackColor="#FFFFC0" />
                <Columns>
                    <asp:CommandField HeaderText="Select" SelectText="Ticket" ShowSelectButton="True" />
                    <asp:BoundField DataField="job_date" DataFormatString="{0:d}" HeaderText="Job Date" SortExpression="JobDate" >
                        <ItemStyle Font-Size="Small" HorizontalAlign="Left" />
                    </asp:BoundField>
                    <asp:BoundField DataField="job_number" HeaderText="Job Number" SortExpression="JobNmber" />
                    <asp:BoundField DataField="cost_code" HeaderText="Cost Code" SortExpression="CostCode" />
                    <asp:BoundField DataField="qty_delivered" HeaderText="Qty Delivered - Asphalt" ReadOnly="True">
                        <ItemStyle HorizontalAlign="Right" Width="120px" />
                        <HeaderStyle Wrap="False" />
                    </asp:BoundField>
                    <asp:BoundField DataField="qty_received" HeaderText="Qty Received - Job">
                        <ItemStyle HorizontalAlign="Right" Width="120px" />
                    </asp:BoundField>
                    <asp:BoundField DataField="qty_used" HeaderText="Qty Used - Job">
                        <ItemStyle HorizontalAlign="Right" Width="120px" />
                    </asp:BoundField>
                    <asp:BoundField DataField="qty_wasted" HeaderText="Qty Wasted - Job">
                        <ItemStyle HorizontalAlign="Right" Width="120px" />
                    </asp:BoundField>
                    <asp:BoundField DataField="plant_id" HeaderText="Plant Id" SortExpression="PlantId" />
                </Columns>
                <SelectedRowStyle BackColor="White" />
    </asp:GridView>
    Last edited by snufse; May 14th, 2008 at 11:23 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width