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

Simple paging and sorting RadGrid

1 Answer 109 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Thomas Maxwell
Top achievements
Rank 1
Thomas Maxwell asked on 13 Jan 2012, 09:01 PM
Hi,
After searching around and not finding an answer I deicded to post...
Working on a project with several RadGrids in it.

The problem is the same across the board...

The code is using LinQtoSQL and Datatables...

An example would look like...
Private Sub btnSearch_Click(sender, e) handles btnSearch_Click()
DoSearch
End sub

Private Sub DoSearch()
using db as new DataContext

dim dt as new datatable
dt.columns.Add("UserName")
dt.columns.Add(UserImage")

dim users = _
from u in db.Users where u.UserName.Contains(txtSearch.Text)
Select u

for each u in users

dim dr as datarow = dt.newrow
dr.item("UserName") = u.username

if not isdbnull(u.Image) and not u.Image = "" then
dr.item("UserImage") = u.UserImage
else
dr.item("UserImage") = "Images/NoImage.gif"
end if

dt.rows.add(dr)

next

end using

RadGrid1.DataSource = dt
RadGrid1.Databind()

End Sub


If I use need data source by eliminating the databind in above and calling DoSearch in need datasource, the button click get ignored

but the larger issue is having to perform the entire search again just to page or sort...

I am not dealing with 10's of thousands of records, maybe 5k max and can pull what I need when a search is complete, but do not want to have to pull all records down just to page or sort the grid...

Short of writing a bunch of code to re-parametor the search, what is the best way to accomplish what I need with the RadGrid?


1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 16 Jan 2012, 05:10 AM
Hello Thomas,

In order to implement advanced features in RadGrid like paging, sorting etc, make sure that you are binding the grid with Advanced data binding using its NeedDataSource event. Check the following help documentation which explains more about this.
Advanced Data-binding (using NeedDataSource event).

-Shinu.
Tags
Grid
Asked by
Thomas Maxwell
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or