Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Button click event comes after GridView bind
Message
From
22/06/2011 11:58:29
Don Harris
Iu Athletics Computer Services
Indiana, United States
 
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
01513130
Message ID:
01515530
Views:
52
>Don,
>
>,
>> I don't know if this is because I'm binding to an entitylist or if it's something dumb I'm doing.
>>
>>I have a button that triggers a search and then should populate a gridview with the entitylist of that search. However,
>>I cannot get it to bind to the data in the click event of the button. If I click the button, the first time through
>>nothing happens. If I click it the second time, it populates fine. The data is always one click behind the
>>button. As you can see I've tried binding and rebinding all over the place but I seem to be missing some
>>clue about the page life cycle or binding in general.
>
>In an ASP.NET app, when you click the button, the web form's Page_Load() fires first, and since you have clicked the button, IsPostBack is true, and your foreach loop executes. Next, your btnMoveToNewYear_Click() method fires and the code overwrites the EntityList you created in the page load.
>
>Are you using the MM .NET data binding properties?
>
>Best Regards,

Kevin,
Unfortunately, I'm not using the MM.NET data binding properties. I'm using the Telerik controls and have had problems with an upgrade I did. I think it's fixed now but I haven't pulled off my project to wrangle the MM.NET Telerik controls back into place. I've been under the gun and trying to code around it......and that's the least of my MM.NET sins. I think I may have something fundamentally wrong with my understanding of the framework (or maybe OOP in general) that's kicking my rear but I'll save that for another post.

I think I stumbled onto the answer to the issue of this post. First of all, I should have left out the Page_Load switch statement as it doesn't apply as I see it to the problem. The first time the button is clicked, there are no session variables so no cases match and no EntityLists get overwritten. It drops straight down to the button_click code.
What seems to have worked is to move the myGrid.DataSource = this.oBizObj.EntityList; statement from the Page_Load to the Button_Click handler. I thought that putting it in the Page_Load would set the stage for it being used by any method/handler that might need it but it didn't seem to. I've also discovered the telerik myGrid_NeedDataSource() handler which I think is taking care of things.

Thanks!

Don
Previous
Reply
Map
View

Click here to load this message in the networking platform