troubleshooting Question

GridView Sorting with LING

Avatar of ksfok
ksfok asked on
ASP.NET
11 Comments1 Solution417 ViewsLast Modified:
Given the following HTML and codebehind:

 <form id="form1" runat="server">
    <div>
        <asp:GridView ID="Gridview1" runat="server" AutoGenerateColumns="False" BackColor="White"
            BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Horizontal"
            AllowSorting="true">
            <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
            <Columns>
                <asp:BoundField DataField="Ename" HeaderText="Employee Name" SortExpression="Ename" />
                <asp:BoundField DataField="AnnSal" HeaderText="Annual Salary" DataFormatString="{0:c}"
                    SortExpression="AnnSal" />
            </Columns>
            <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
            <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
            <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
            <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
            <AlternatingRowStyle BackColor="#F7F7F7" />
        </asp:GridView>
    </div>
    </form>

   Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load

        If Not IsPostBack Then

            Dim query = From p In GetEmployeeList() Select p.Ename, AnnSal = (p.Sal * 12)

            Me.Gridview1.DataSource = query

            Me.Gridview1.DataBind()

        End If

    End Sub

The grid is populated OK but clicking on a field to sort generate this error:

The GridView 'Gridview1' fired event Sorting which wasn't handled.

How can event sorting handler be coded here?

Thanks for any help.

 
ASKER CERTIFIED SOLUTION
Eladla

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 11 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros