Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can I enable GridView paging if Grid is bound to data source programma

Status
Not open for further replies.

Valeriya

MIS
Jan 9, 2006
138
US
Hi. I have a problem with my GridView (asp.net 2.0)...Here is what I'm doing. My GridView is bound (HTML tags) to a
DataSet. This GridView displays about 8,000 records (paging is enabled). I have added a TextBox which works as a filter on the GridView. User enters search value in this text box, clicks a button and GridView displays the record user is searching for. Here is what the problem is: When user clicks the search button my GridView is programmatically re-bound to a different DataSource, so that I displays a single record, which works fine. However, I want to be able to go to the previous display of 8,000 records (paged). So again, I re-bind my GridView to the original DataSource. Of course binding, is done programmatically. But now my paging does not work. It worked in the beginning before I've done programmatic re-binding, but not now. Can anybody suggest how I need to go about fixing this problem? Is there any material on the web concerning this issue?

Thanks a lot!


Valeriya
 
But now my paging does not work.
You'll have to be more specific if you want any help.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Sure, I get this is the exception:

The GridView 'GridView1' fired event PageIndexChanging which wasn't handled.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The GridView 'GridView1' fired event PageIndexChanging which wasn't handled.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[HttpException (0x80004005): The GridView 'GridView1' fired event PageIndexChanging which wasn't handled.]
System.Web.UI.WebControls.GridView.OnPageIndexChanging(GridViewPageEventArgs e) +323
System.Web.UI.WebControls.GridView.HandlePage(Int32 newPage) +110
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +516
System.Web.UI.WebControls.GridView.RaisePostBackEvent(String eventArgument) +213
System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +31
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +32
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +242
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3835


Does it help or you actually need the code?
Thanks!



 
The GridView 'GridView1' fired event PageIndexChanging which wasn't handled.
You'll have to create a PageIndexChanging event for the GridView.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Thank you very much for your quick answer! I don’t understand why it works, but it does. I created the event, with no code inside and it took care of the problem. What was causing the problem and why did adding event resolve it?

Thanks you again for your kind help!!!
Valeriya
 
When the user pages the GridView, the PageIndexChanging event is fired. If there is no event handler it falls over. It seems kind of odd to me too (that it errors), but that's what happens.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Actually, I suppose it does make sense. You've set the AllowPaging property to True so it's expecting to page the GridView. If you don't then specify an event to handle this paging, it errors.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top