How can I modify a custom object in an ASP.NET FormView based on a button click?
- by David
I have a FormView that modifies an instance of a custom class. The various form controls (TextBox, DropDownList etc.) are working fine. However, I want to include a Button that will modify the state of the DataItem based on some very simple logic. There is no form control which could control this change in a non-confusing way.
So I tried adding a Button and modifying the state of the DataItem in the code-behind. But the problem I encounter is that the FormView's DataItem is null/nothing. From reading this SO question it seems the problem is that the item is not databound when the Button's Click event is fired.
So, the question; Is it possible to get the DataItem for the FormView during a Button's Click event? and if not: what are my options for implementing this?
Thanks in advance.
Edit: I can include any code that might help