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"%>
<html>
<head><title>Multiple Selections</title></head>
<body>
<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:listBox>
<asp:DropDownList id="SortList1" Runat="server" Font-Bold="False" Font-Italic="False" Width="128px" >
<asp:ListItem Text="astate" />
</asp:DropDownList>
<asp:DropDownList ID="DirectionList" runat="server" Font-Bold="False" Font-Italic="False">
<asp:ListItem Text="Ascending">
</asp:ListItem>
<asp:ListItem Text="Descending">
</asp:ListItem>
</asp:DropDownList><br />
<br />
<br />
<br />
<asp:GridView ID="gvEmployee" runat="server" />
<br />
<br />
<br />
<asp:button id="SortButton" text="Search" onclick="SortButton_Click" runat="Server" />
</form>
</body>
</html>
<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"
objConnection.Open()
Dim objCommand As New OleDbCommand(strSQLforListBox, objConnection)
lstListBox.DataSource = objCommand.ExecuteReader()
lstListBox.DataTextField = "astate"
lstListBox.DataValueField = "astate"
lstListBox.DataBind()
objConnection.Close()
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
Next
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)
objConnection.Open()
Dim objCommand As New OleDbCommand(strSQLforGrid, objConnection)
' Remove next line prior to deployment
Response.Write("strSQLforGrid = <br/>" & strSQLforGrid & "")
gvEmployee.DataSource = objCommand.ExecuteReader()
gvEmployee.DataBind()
objConnection.Close()
Else
gvEmployee.Visible = False
End If
End Sub
Sub SortButton_Click(ByVal sender As Object, ByVal e As EventArgs)
BindVendor()
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
</script>