This is a migrated thread and some comments may be shown as answers.

Yet Another NeedDataSource Question

1 Answer 39 Views
Grid
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 15 Jun 2011, 08:04 PM
Hey guys, did a search of the forums and haven't found exactly what I needed so I figured I would ask here.

I am using databinding to hydrate my radgrid and everything was working fine.  The problem started when I wanted to sort and filter the grid.

I realized quickly the need for a NeedDataSource sub and put it to use.  However when I attempted to clean up the code and put my logic in its own sub, I run into problems.  If I throw the code from the hydrategrid sub into the NeedDataSource sub, as well as the button click sub the page sorts fine.

If I break the code into the HydrateGrid sub then when I hit the sort button or apply a filter, the grid shows empty.

I have simplified the HydrateGrid sub but here is my code:

Protected Sub HydrateGrid(ByVal bindit As Boolean)
Try
radgrdResults.DataSource = searchvalues.Fetch(gd)
                If bindit = True Then
                    radgrdResults.DataBind()
                End If
            Catch ex As Exception
                Throw ex
            End Try
 
        End Sub
 
Protected Sub searchButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles searchButton.Click
            Try
                ' hydrate grid with data
                HydrateGrid(True)
            Catch ex As Exception
                Throw ex
            End Try
             
        End Sub
        Protected Sub radgrdResults_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs)
            Try
                ' Hydrate grid with data but don't bind
                HydrateGrid(False)
            Catch ex As Exception
                Throw ex
            End Try
 
        End Sub

1 Answer, 1 is accepted

Sort by
0
John
Top achievements
Rank 1
answered on 15 Jun 2011, 09:42 PM
Nevermind, I figured it out.

I had this in the wrong section of the ASPX:
OnNeedDataSource="radgrdResults_NeedDataSource"
Tags
Grid
Asked by
John
Top achievements
Rank 1
Answers by
John
Top achievements
Rank 1
Share this question
or