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

strange issue with grid paging

2 Answers 65 Views
Grid
This is a migrated thread and some comments may be shown as answers.
newbie
Top achievements
Rank 1
newbie asked on 06 Mar 2009, 08:48 PM
I have a search textbox on my page I bind my grid on click of find button like this:

 

 

protected

void BtnSearch_Click(object sender, ImageClickEventArgs e)

 

 

 

 

{

soHelper =

new SmartOfficeHelper();

 

 

DataTable dtContact = soHelper.SearchSmartOffice(RadTextBoxName.Text);

 

ViewState[

"dtContact"] = dtContact;

 

RadGridContact.DataSource = dtContact;

RadGridContact.Rebind();

 

if (dtContact.Rows.Count > 0)

 

{

RadGridContact.Visible =

true;

 

}

}


If i change the page and then try to do a different search my grid shows no records.
If i don't change the page then everything works fine.

protected

void RadGridContact_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)

 

{

 

 

if (e.RebindReason == GridRebindReason.InitialLoad)

 

{

 

DataTable emptyTable = new DataTable();

 

RadGridContact.DataSource = emptyTable;

}

 

else if (e.RebindReason == GridRebindReason.PostBackEvent)

 

{

soHelper =

new SmartOfficeHelper();

 

 

DataTable dtContact = soHelper.SearchSmartOffice(RadTextBoxName.Text);

 

RadGridContact.DataSource = dtContact;

}

}

 


Am I doing something wrong?

2 Answers, 1 is accepted

Sort by
0
newbie
Top achievements
Rank 1
answered on 06 Mar 2009, 08:54 PM
ok I figured out the problem, but i still don't know why it's doing that.

The grid seems to be rem'bering the page number. So if i go to page 2 and then type something in the textbox that loads results that are only 1 page then the grid shows no records.
If I type something that has multiple pages then my grid shows.

Why is this happening?
0
Sebastian
Telerik team
answered on 07 Mar 2009, 08:33 AM
Hello newbie,

The behavior you observed is expected. If you would like to reset the page index of the grid when performing a new search and loading a different set of data in the control, merely set its CurrentPageIndex property to 0 before invoking the Rebind() method of the grid to refresh it.

Kind regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
newbie
Top achievements
Rank 1
Answers by
newbie
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or