How can I modify a custom object in an ASP.NET FormView based on a button click?

Posted by David on Stack Overflow See other posts from Stack Overflow or by David
Published on 2010-04-22T02:46:31Z Indexed on 2010/04/22 2:53 UTC
Read the original article Hit count: 293

Filed under:
|
|

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

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about formview