dataview, datagrid and sorting

jvcoach23

Centurion
Joined
May 22, 2003
Messages
192
Location
Saybrook, IL
I've searched around.. really I have.. but either haven't found the answer or not good enough to interpret what I've found.

I have a datagrid that I've bound some columns to from teh output of a stored procedure. I've renamed the column heading but told the grid to allow sorting and entered in the column names as given to me by the sp in the sorting field of the datagrid.

I've bound the datagrid.source = dataview and am getting a result back. Then, when I click on the column header to fire off the soft event.. I get this error.

datatable must be set prior to using dataview

what am I doing wrong.. here is the code to the sortcommand

Visual Basic:
 Private Sub dgNetMonFind_SortCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles dgNetMonFind.SortCommand
        Me.dvNetMonFindComputer.Sort = e.SortExpression

        Me.dgNetMonFind.DataBind()
    End Sub

the e.sortexpression shows to be = "vcComputerName".. that is the columnName that is coming in from the sp. Can somone help me out..

Visual Basic:
Private Sub cmdSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSubmit.Click

        Dim Query As String
        Query = Me.txtNetMonFind.Text

        With Me.spNetMonFindComputer
            .Parameters("@query").Value = Query

            Me.cnSql.Open()
            .ExecuteNonQuery()
            Me.cnSql.Close()
        End With

        Me.daNetMonFindComputer.Fill(Me.dsNetMonFindComputer)
        Me.dvNetMonFindComputer = New DataView(Me.dsNetMonFindComputer.Tables(0))

        With Me.dgNetMonFind
            .DataSource = Me.dvNetMonFindComputer
            .DataBind()
            .Visible = True
        End With


    End Sub
thanks
shannon
 
will this cost me another trip to the database.. I was hoping to not have to do that.. only because i figured it would be more effiecient not to..
 
Back
Top