Link to home
Start Free TrialLog in
Avatar of markofsoton
markofsoton

asked on

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
Avatar of Ramuncikas
Ramuncikas
Flag of Lithuania image

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
Avatar of markofsoton
markofsoton

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Ramuncikas
Ramuncikas
Flag of Lithuania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial