?
Solved

Datagrid based on dataview not displaying records

Posted on 2005-05-05
3
Medium Priority
?
326 Views
Last Modified: 2010-04-07
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
0
Comment
Question by:markofsoton
  • 2
3 Comments
 
LVL 14

Expert Comment

by:Ramuncikas
ID: 13934753
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
 

Author Comment

by:markofsoton
ID: 13935128
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
 
LVL 14

Accepted Solution

by:
Ramuncikas earned 375 total points
ID: 13943064
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question