0
votes

I have a Asp.Net webform which contains a gridview control and pagenavigation usercontrol. There is property exposed by the user control which sets the instance of the gridview control. The instance is passed from the webform the first time the page is loaded.when I click the next button of the pagenavigation user control to traverse to the next page, the gridview control object in the usercontrol is null.

Could you let me know why this is happening? The gridview control was correctly set the first time ? Why is the giving object instance not set error while traversing? How to get around this issue ?

1

1 Answers

0
votes

Either. What I was really trying to determine when you say instance is whether it is dynamically created and added to the page's control collection or through the designer and a element.

If it's done in codebehind like:

GridView v = new GridView();
this.Controls.Add(v);

then you definitely must recreate it each time in the OnLoad event of the Page (or control it's created in) in order to be available. What's more, it must have the exact same name each and every time. Otherwise it won't match up the viewstate information from the previous time.