I am using a GridView in ASP.NET and am building it up programmatically. However, when I go to sort, I am getting an error thrown because the event is not being handled correctly.
I've not worked with ASP.NET GridViews in a long time and am extremely rusty on this one.
This is the code I have so far:
Public Sub GetData()
Using sqlConn As New SqlConnection(_connstr)
Dim sqlcmd As New SqlCommand()
sqlcmd.Connection = sqlConn
sqlcmd.CommandType = CommandType.StoredProcedure
sqlcmd.CommandText = "dbo.uspGetEmailAudit"
sqlcmd.Parameters.Add(requestIdParam)
Using sqlda As New SqlDataAdapter(sqlcmd)
sqlda.Fill(_dt)
End Using
End Using
BindData(_dt)
End Sub
Private Sub BindData(dt As DataTable)
GridView1.DataSource = _dt
GridView1.AllowSorting = True
GridView1.AllowPaging = True
GridView1.PageSize = 15
GridView1.DataBind()
End Sub
Protected Sub sorting(sender As Object, e As GridViewSortEventArgs)
ViewState("sortexp") = e.SortExpression
GridView1.DataSource = GetData()
GridView1.DataBind()
End Sub
The error that I am getting is:
The GridView 'GridView1' fired event Sorting which wasn't handled.
GridView1to handle theSortingevent? - j.f.