SortCommand in datagrid, dataview....

2

276q

Trying to use the sortcommand in my datagrid, the subroutine
"Sort_Grid" error message is prompting: Name 'objDataView' is not
declared.
'''''''''
Sub bindSwGrid()
Dim strSQL As String = "SELECT * FROM cards"
Dim objConnection As New SQLConnection(strConnection)
Dim objAdapter As New SQLDataAdapter(strSQL,
objConnection)
Dim objDataSet As New DataSet()

objAdapter.Fill(objDataSet, "cards")

Dim objDataView As New
DataView(objDataSet.Tables("cards"))

swGrid.DataSource = objDataView
swGrid.DataBind()
End Sub

Sub Sort_Grid(sender As Object, e As DataGridSortCommandEventArgs)
objDataView.Sort = e.SortExpression

swGrid.DataBind()
End Sub
''''''''''
??
Ed
 
G

Guest

You declared objDataView in bindSwGrid procedure - therefore it is only
visible inside that procedure (and not in Sort_Grid where you are referencing
it).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top