SortCommand in datagrid, dataview....

Discussion in 'ASP .Net' started by 276q@cox.net, Jul 3, 2007.

  1. Guest

    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
     
    , Jul 3, 2007
    #1
    1. Advertising

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


    "" wrote:

    > 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
    >
    >
     
    =?Utf-8?B?U2VyZ2V5IFBvYmVyZXpvdnNraXk=?=, Jul 3, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ken Tucker
    Replies:
    2
    Views:
    2,572
    Ken Tucker
    Jul 6, 2003
  2. John Sturgeon

    DataGrid SortCommand event not triggered

    John Sturgeon, Nov 26, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    587
    John Sturgeon
    Dec 2, 2003
  3. Mo
    Replies:
    0
    Views:
    468
  4. CodeMonkey
    Replies:
    1
    Views:
    738
    joyal jhaveri
    Feb 4, 2011
  5. biru
    Replies:
    2
    Views:
    233
Loading...

Share This Page