FormView // ViewState interaction and ItemCommands
This is probably a page life cycle thing I'm not completely following, but I have the following problem. I have a gridview object and a formview object. When the gridview is clicked, the formview is populated.
When I am in formview inserting mode, everything works perfectly. When I am in formview edit mode, the buttons do not reach the ItemCommand method. I have tested this by adding a breakpoint to my code and every time, the save button from the insert method reaches the command but not the edit mode.
from the EditItemTemplate
<asp:Button ID="btnSave" runat="server" CommandName="Update"
Text="Save" meta:resourcekey="btnSaveResource2" />
<asp:Button ID="btnCancel" runat="server" CommandName="Cancel" Text="Cancel"
meta:resourcekey="btnCancelResource2" />
From the InsertItemTemplate :
<asp:Button ID=开发者_如何学编程"btnAdd" runat="server" CommandName="Insert"
Text="Save" meta:resourcekey="btnAddResource1" />
<asp:Button ID="btnCancel" runat="server" CommandName="Cancel" Text="Cancel"
meta:resourcekey="btnCancelResource3" />
FormView
<asp:FormView ID="poolEditFV" runat="server" OnItemCommand="poolEditFV_ItemCommand"
EnableViewState = "False" OnModeChanging="poolEditFV_ModeChange"
meta:resourcekey="poolEditFVResource1">
Now, I don't really want the items in this form in the ViewState, but I tried enabling the view state anyhow. When I enable it, the ItemCommand method is properly reached. However... if I clicked edit, cancel, edit, I get a huge ViewState error (probably because my FormView is being updated programmatically in the middle of the page's lifecycle).
Can anyone offer me some help on this one? I don't know how to get the edit items to actually fire commands unless I use the ViewState (which I don't really want to) and that creates errors of its own.
Thank you.
精彩评论