Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old July 27th, 2006, 10:05 AM
Registered User
Join Date: Jul 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default fired event Sorting which wasn't handled

hi all,
Hope someone will look at it and point me where i made the mistake. attaced the error msg i got and do not have much clue or what to do about the error msg. if you have an idea please share it with me and i really appreciate your time and help.

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

The GridView 'gvEmployee' fired event Sorting which wasn't handled.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The GridView 'gvEmployee' fired event Sorting which wasn't handled.

Source Error:

Line 105: End Select
Line 106:
Line 107: gvEmployee.Sort(expression, direction)
Line 108:
Line 109: End Sub

<%@ Import namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb"%>

  <head><title>Multiple Selections</title></head>
    <h3>Multiple Selections</h3>
    <form id="Form1" runat="server">
         <asp:listBox id = "lstListBox" selectionmode=Multiple Runat="server" AppendDataBoundItems="True" >
         <asp:ListItem Value="state">-- State--</asp:ListItem>
        <asp:DropDownList id="SortList1" Runat="server" Font-Bold="False" Font-Italic="False" Width="128px" >
        <asp:ListItem Text="astate" />
        <asp:DropDownList ID="DirectionList" runat="server" Font-Bold="False" Font-Italic="False">
            <asp:ListItem Text="Ascending">
            <asp:ListItem Text="Descending">
        </asp:DropDownList><br />
      <br />
       <br />
        <br />
         <asp:GridView ID="gvEmployee" runat="server" />

        <br />
       <br />
        &nbsp;<br />
        <asp:button id="SortButton" text="Search" onclick="SortButton_Click" runat="Server" />

<script language="vb" runat="server">

    Dim myConnection As OleDbConnection
    Dim connectionString As String
    Sub Page_Load(ByVal Source As Object, ByVal E As EventArgs)

        If Not IsPostBack Then
            connectionString = "provider=MSDAORA;Data Source=tplp;User ID=tplcp;Password=tplcp;"
            Dim objConnection As New OleDbConnection(connectionString)
            Dim strSQLforListBox As String = "SELECT distinct astate FROM VENDADDR ORDER BY astate"
            Dim objCommand As New OleDbCommand(strSQLforListBox, objConnection)
            lstListBox.DataSource = objCommand.ExecuteReader()
            lstListBox.DataTextField = "astate"
            lstListBox.DataValueField = "astate"
        End If
    End Sub

    Sub BindVendor()

        Dim strWhereClause As String = ""
        Dim liThisOne As ListItem
        For Each liThisOne In lstListBox.Items
            If liThisOne.Selected Then
                strWhereClause += "astate=" & "'" & liThisOne.Value & "'" & " OR "
            End If


        If strWhereClause.Length > 0 Then
            gvEmployee.Visible = True
            strWhereClause = Left(strWhereClause, strWhereClause.Length - 4)
            connectionString = "provider=MSDAORA;Data Source=tplp;User ID=tplcp;Password=tplcp;"
            Dim strSQLforGrid As String = "SELECT vendor,astate,acity FROM VENDADDR where " & strWhereClause & "order by vendor"

            Dim objConnection As New OleDbConnection(connectionString)
            Dim objCommand As New OleDbCommand(strSQLforGrid, objConnection)

            ' Remove next line prior to deployment
            Response.Write("strSQLforGrid = <br/>" & strSQLforGrid & "")
            gvEmployee.DataSource = objCommand.ExecuteReader()

            gvEmployee.Visible = False
        End If
    End Sub

    Sub SortButton_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim expression As String = ""
        Dim direction As SortDirection
        expression = SortList1.SelectedValue
        Select Case DirectionList.SelectedValue

            Case "Ascending"
                direction = SortDirection.Ascending
            Case "Descending"
                direction = SortDirection.Descending
            Case Else
                direction = SortDirection.Ascending

        End Select

        gvEmployee.Sort(expression, direction)

    End Sub


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to suspend code till Activex event is handled fossx VB How-To 1 June 1st, 2007 10:57 AM
SortCommend event is being fired twice anup_daware .NET Framework 2.0 2 August 9th, 2006 12:19 AM
SortCommend event is being fired twice anup_daware .NET Framework 1.x 1 August 4th, 2006 05:32 AM
setting event handled to true sajid C# 3 April 27th, 2005 12:02 PM
Session_Start event not fired rl ASP.NET 1.0 and 1.1 Professional 20 February 22nd, 2005 04:29 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.