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

RadGrid Sorting not Working

4 Answers 235 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 01 Mar 2013, 07:18 PM
I am using a RadGrid and sorting is not working.  As an experiment I removed my grid and replaced with the grid from the
"Grid - Advanced Data Binding" demo. http://demos.telerik.com/aspnet-ajax/grid/examples/programming/needdatasource/defaultvb.aspx?#qsf-demo-source 

I linked to my data: RadGrid1.DataSource = GetSearchData() and the grid appeared displaying my data but sorting does not work.

When I click to sort,
        Protected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
            RadGrid1.DataSource = GetSearchData()
        End Sub

is called.  The data is returned but it is not sorted,

Any idea how I can get sorting to work?

4 Answers, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 06 Mar 2013, 12:22 PM
Hi David,

Could you please post the definition of GetSearchData()  method. Also could you please confirm that you do not return different data on every GetSearchData() call?

Looking forward for your reply.

Regards,
Radoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
David
Top achievements
Rank 1
answered on 06 Mar 2013, 07:08 PM

 

Definition of GetSearchData()  method. I do not return different data on every GetSearchData() call.
'''
<summary>

 

 

''' GetSearchData

 

 

''' </summary>

 

 

''' <returns></returns>

 

 

''' <remarks></remarks>

 

 

Private Function GetSearchData() As IEnumerable(Of PTAR_Search_PermitsResult)

 

 

Dim iPermitTypeId As Nullable(Of Integer) = Nothing

 

 

Dim iPermitSubTypeId As Nullable(Of Integer) = Nothing

 

 

Dim iSiteId As Nullable(Of Integer) = Nothing

 

 

Dim iFacilityId As Nullable(Of Integer) = Nothing

 

 

Dim iPermitId As String = Nothing

 

 

Dim iEmployeeId As Nullable(Of Integer) = Nothing

 

 

Dim dtExpireDateFrom As Nullable(Of Date) = Nothing

 

 

Dim dtExpireDateTo As Nullable(Of Date) = Nothing

 

 

Dim dtCreatedDateFrom As Nullable(Of Date) = Nothing

 

 

Dim dtCreatedDateTo As Nullable(Of Date) = Nothing

 

 

Dim iEmployeeCoCd As Nullable(Of Integer) = Nothing

 

 

Dim ContactPrim As Nullable(Of Char) = Nothing

 

 

Dim iPermitCoCd As Nullable(Of Integer) = Nothing

 

 

Dim iPermitOrgCd As Nullable(Of Integer) = Nothing

 

 

Dim iPermitStatus As Nullable(Of Integer) = Nothing

 

 

Dim Descr As String = Nothing

 

 

Dim County As String = Nothing

 

 

Dim iAgencyId As Nullable(Of Integer) = Nothing

 

 

Try

 

dtExpireDateTo = Convert.ToDateTime(txt_expTo.Value.Trim(), CultureInfo.CurrentCulture)

 

Catch ex As FormatException

 

dtExpireDateTo =

Nothing

 

 

Catch ex As InvalidCastException

 

dtExpireDateTo =

Nothing

 

 

End Try

 

 

Try

 

dtExpireDateFrom = Convert.ToDateTime(txt_expFr.Value.Trim(), CultureInfo.CurrentCulture)

 

Catch ex As FormatException

 

dtExpireDateFrom =

Nothing

 

 

Catch ex As InvalidCastException

 

dtExpireDateFrom =

Nothing

 

 

End Try

 

iEmployeeId = empsrch_contact.EmpID

 

If iEmployeeId = 0 Or iEmployeeId = -1 Then

 

iEmployeeId =

Nothing

 

 

End If

 

iEmployeeCoCd = empsrch_contact.CoCd

 

If iEmployeeCoCd = 0 Or iEmployeeCoCd = -1 Then

 

iEmployeeCoCd =

Nothing

 

 

End If

 

 

If chkPrim.Checked Then

 

ContactPrim =

CChar("Y")

 

 

End If

 

 

Try

 

iPermitId = txt_permId.Value.Trim()

 

Catch ex As InvalidCastException

 

iPermitId =

Nothing

 

 

Finally

 

 

If iPermitId.Trim() = "" Then

 

iPermitId =

Nothing

 

 

End If

 

 

End Try

 

 

Try

 

iFacilityId = Convert.ToInt32(ddl_fac.SelectedValue, CultureInfo.CurrentCulture)

 

Catch ex As InvalidCastException

 

iFacilityId =

Nothing

 

 

Catch ex As FormatException

 

iFacilityId =

Nothing

 

 

Finally

 

 

If iFacilityId = 0 Or iFacilityId = -1 Then

 

iFacilityId =

Nothing

 

 

End If

 

 

End Try

 

 

Try

 

iSiteId = Convert.ToInt32(ddl_site.SelectedValue, CultureInfo.CurrentCulture)

 

Catch ex As InvalidCastException

 

iSiteId =

Nothing

 

 

Catch ex As FormatException

 

iSiteId =

Nothing

 

 

Finally

 

 

If iSiteId = 0 Or iSiteId = -1 Then

 

iSiteId =

Nothing

 

 

End If

 

 

End Try

 

 

Try

 

iPermitSubTypeId = Convert.ToInt32(ddl_subType.SelectedValue, CultureInfo.CurrentCulture)

 

Catch ex As InvalidCastException

 

iPermitSubTypeId =

Nothing

 

 

Catch ex As FormatException

 

iPermitSubTypeId =

Nothing

 

 

Finally

 

 

If iPermitSubTypeId = 0 Or iPermitSubTypeId = -1 Then

 

iPermitSubTypeId =

Nothing

 

 

End If

 

 

End Try

 

 

Try

 

iPermitTypeId = Convert.ToInt32(ddl_type.SelectedValue, CultureInfo.CurrentCulture)

 

Catch ex As FormatException

 

iPermitTypeId =

Nothing

 

 

Finally

 

 

If iPermitTypeId = 0 Or iPermitTypeId = -1 Then

 

iPermitTypeId =

Nothing

 

 

End If

 

 

End Try

 

 

Try

 

iPermitCoCd = Convert.ToInt32(ddl_comp.SelectedValue, CultureInfo.CurrentCulture)

 

Catch ex As FormatException

 

iPermitCoCd =

Nothing

 

 

Finally

 

 

If iPermitCoCd = 0 Or iPermitCoCd = -1 Then

 

iPermitCoCd =

Nothing

 

 

End If

 

 

End Try

 

 

Try

 

iPermitOrgCd = Convert.ToInt32(ddl_org.SelectedValue, CultureInfo.CurrentCulture)

 

Catch ex As FormatException

 

iPermitOrgCd =

Nothing

 

 

Finally

 

 

If iPermitOrgCd = 0 Or iPermitOrgCd = -1 Then

 

iPermitOrgCd =

Nothing

 

 

End If

 

 

End Try

 

 

Try

 

iPermitStatus = Convert.ToInt32(ddl_stat.SelectedValue, CultureInfo.CurrentCulture)

 

Catch ex As FormatException

 

iPermitStatus =

Nothing

 

 

Finally

 

 

If iPermitStatus = 0 Or iPermitStatus = -1 Then

 

iPermitStatus =

Nothing

 

 

End If

 

 

End Try

 

 

Try

 

County = ddl_county.SelectedValue

 

Catch ex As FormatException

 

County =

Nothing

 

 

Finally

 

 

If County = "-1" Then

 

County =

Nothing

 

 

End If

 

 

End Try

 

Descr = txt_descr.Text.Trim

 

Try

 

iAgencyId = Convert.ToInt32(ddl_agency.SelectedValue, CultureInfo.CurrentCulture)

 

Catch ex As FormatException

 

iAgencyId =

Nothing

 

 

Finally

 

 

If iAgencyId = 0 Or iAgencyId = -1 Then

 

iAgencyId =

Nothing

 

 

End If

 

 

End Try

 

 

Return searchPermitsDAL.SearchPermits(iPermitTypeId, iPermitSubTypeId, iSiteId, iFacilityId, _

 

iPermitId, iEmployeeId, iEmployeeCoCd, ContactPrim, _

dtExpireDateFrom, dtExpireDateTo, dtCreatedDateFrom, dtCreatedDateTo, _

iPermitCoCd, iPermitOrgCd, iPermitStatus, County, Descr, iAgencyId)

 

End Function

 

0
Radoslav
Telerik team
answered on 11 Mar 2013, 08:09 AM
Hi David,

I reviewed the GetSearchData function and it looks correct. If it returns the same data before sorting and after that it can’t be the cause of the described behavior. Another reason for the described issue could be if your RadGrid performs ajax requests but it is not ajaxified control. If you are using an ajax on you page could you please try removing all UpdatePanels or set EnableAjax=”false” to any RadAjaxManager or RadAjaxPanel and let me know if the issue still persists?

Looking forward for your reply.

All the best,
Radoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
David
Top achievements
Rank 1
answered on 26 Mar 2013, 08:04 PM
Changing RadGrid1.DataSource = GetSearchData() to
RadGrid1.DataSource = GetSearchData().ToList()
fixed the issue.
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
David
Top achievements
Rank 1
Share this question
or