views:

1352

answers:

1

I have a user control that has a gridview in it with paging. The paging is driven by an object datasource, so it's using the dopostback events by default.

I want to use jquery to load the usercontrol into a tab via ajax because I have multiple tabs that I don't want to load all at once and take all the database hits if they aren't needed.

So I put that user control on a blank aspx file and set the tab's href = to that aspx file. The gridview loads fine and looks great.

The problem I am running into is when I try to change pages on the gridview, the postback is going to the URL of the aspx file and not the page I am on with the tabs. I know this is supposed to happen, but I am wondering what I can do to make it so it can post back to the right page and work within the tabs.

It doesn't work with and without an updatepanel around it.

Any help is appreciated.

A: 

You could use the same aspx file for different tabs by using url parameter:

MyTabs.aspx?tab=gridViewOnly

Then on the server side you can check which tab needs to be shown:

string tab = Request.Params["tab"];

if(tab == "gridViewOnly")
{
// make the gridview visible and do only needed calls to DB
}
algiecas