Datagrid based on dataview not displaying records

Hello,

I have a simple dataview based datagrid that populates on an onchange event of a dropdown filter

the dv seems to be populated by the process but the resuting grid only has column headings and no data even though the row count for the dv is 1441

Sub ddStreet_onChange(ByVal Sender As Object, ByVal E As EventArgs)
        Dim CF As New commonFunctions
        Dim dtWard As New DataTable
        dtWard = Cache("dtWard")
        Dim strSelected As String = "STREET_NAME = '" & ddStreet.SelectedValue & "'"

        Dim dv As New DataView

        dv = CF.SelectFromDT(strSelected, "STREET_NAME", dtWard)


        dgSelectPlots.DataSource = dv
        dgSelectPlots.DataBind()

    End Sub

anybody got any ideas

thanks

mark

'select from dt

    Public Function SelectFromDT(ByVal strExpr As String, ByVal strSort As String, ByVal dt As DataTable)

        'Generic function to allow filtering of datatables

        Dim dv As DataView
        dv = New DataView
        With dv
            .Table = dt
            .AllowDelete = True
            .AllowEdit = True
            .AllowNew = True
            .RowFilter = strexpr
            .RowStateFilter = DataViewRowState.ModifiedCurrent
            .Sort = strsort
        End With

        Return dv

    End Function
markofsotonAsked:
Who is Participating?
 
RamuncikasConnect With a Mentor Commented:
Hey, Mark,

Why don't you use ViewState property of the page?

To store datatable to Viewstate use this:
   Me.ViewState("dtWart") = dtWart

To retrieve it from ViewState use this:
   dtWart = CType(Me.ViewState("dtWart"), DataTable)

And of course don't forget to set Page's EnableViewState property to TRUE if it is FALSE.

Let's hope this will do
Ramuncikas
0
 
RamuncikasCommented:
Hi  markofsoton,

I would change your source this way:

Public Function SelectFromDT(ByVal strExpr As String, ByVal strSort As String, ByVal dt As DataTable)

        'Generic function to allow filtering of datatables

'------------ this row
        dv = dt.DefaultView

        With dv
'---------- and would comment the row below
            '.Table = dt
            .AllowDelete = True
            .AllowEdit = True
            .AllowNew = True
            .RowFilter = strexpr
            .RowStateFilter = DataViewRowState.ModifiedCurrent
            .Sort = strsort
        End With

        Return dv

    End Function


Hope this helps
Ramuncikas
0
 
markofsotonAuthor Commented:
it appears to be some problem retrieving the datatable from the cache

i do  

Cache("dtWard") = dtWard to add the dt to the cache

then

dtWard = Cache("dtWard")

the rows don't seem to survive this
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.