Ticket Q229170
Visible to All Users

ASPxGridView - PopupEditForm template controls lose values after a postback

created 14 years ago

Hi team.
I call ASPxPopupControl from EditForm template of ASPxGridView.
ASPxPopupControl is located outside of EditForm template and called from the click on ASPxButtonEdit button.
Here is markup:

ASPx
<dx:ASPxGridView ID="ASPxGridViewUsage" runat="server" AutoGenerateColumns="False" ClientIDMode="AutoID" ClientInstanceName="ASPxGridViewUsage" CssFilePath="~/App_Themes/DevEx/{0}/styles.css" CssPostfix="DevEx" DataSourceID="SqlDataSourceAppointmentUsage" EnableCallBacks="False" Font-Names="Verdana" Font-Size="8pt" KeyFieldName="UsageID" Width="1250px"> ... <Columns> <dx:GridViewDataButtonEditColumn Caption="Invoice To" FieldName="BillingClientName" Name="BillingClientName" VisibleIndex="12" Width="400px" Visible="False"> <PropertiesButtonEdit ClientInstanceName="UsageInvoiceToClientName"> <ClientSideEvents ButtonClick="function(s, e) {PopupAddressBook1.Show();}" /> <Buttons> <dx:EditButton Position="Right" ToolTip="Select Client"> </dx:EditButton> </Buttons> </PropertiesButtonEdit> <EditFormSettings Visible="true" VisibleIndex="12" /> </dx:GridViewDataButtonEditColumn> </Columns> <Templates> <EditForm> <div style="padding: 4px 4px 3px 4px"> <dx:ASPxGridViewTemplateReplacement ID="Editors" runat="server" ReplacementType="EditFormEditors" /> </div> <div style="padding: 4px 4px 3px 4px"> <dx:ASPxButtonEdit ID="ASPxButtonEditUsageInvoiceToClientName" runat="server" ClientIDMode="AutoID" ClientInstanceName="ASPxButtonEditUsageInvoiceToClientName" CssFilePath="~/App_Themes/SoftOrange/{0}/styles.css" CssPostfix="SoftOrange" ReadOnly="True" SpriteCssFilePath="~/App_Themes/SoftOrange/{0}/sprite.css" OnButtonClick="ASPxButtonEditUsageInvoiceToClientName_ButtonClick" Width="300px" Text='<%# Eval("BillingClientName") + ""%>'> <ClientSideEvents ButtonClick="function(s, e) {PopupAddressBook1.ShowAtElement(this);}" /> <Buttons> <dx:EditButton> </dx:EditButton> </Buttons> </dx:ASPxButtonEdit> </div> <div style="text-align: right; padding: 4px 4px 3px 4px"> <dx:ASPxGridViewTemplateReplacement ID="UpdateButton" runat="server" ReplacementType="EditFormUpdateButton" /> <dx:ASPxGridViewTemplateReplacement ID="CancelButton" runat="server" ReplacementType="EditFormCancelButton" /> </div> </EditForm> ... </Templates> </dx:ASPxGridView>

I have few other issues that are related to this scenario of having popoup called from another popup (EditForm).
I remember your rules of opening separate case for it, but maybe in this case it would reduce work for everyone due to you are already familiar with pre-conditions.
So I try to ask.
1)     I populate fields of EditForm popup with default values (when it used for "Insert New" record, but when 2nd popup (Address Book) is called from inside of EditForm it clears those values.
The popup clears only default values that were passed during ASPxGridViewUsage_CellEditorInitialize event when EditForm is been opened for the 1st time.
The value that are typed in or selected directly on the EditForm stay put when popup is called no matter how many time which is normal and expected.
Where should I look to prevent both issues from happening?
thanks

Answers approved by DevExpress Support

created 14 years ago (modified 12 years ago)

Hi Alex,
In your markup, I see that you are using the EditForm template. I would like to note that ASPxGridView templates do not keep their values. It means that the latter will be lost after a postback sent to paginate, sort, filter, etc. the grid. Thus, it is necessary to save the control value into a database just after it has been input or avoid performing postbacks.
I see that you handle the ASPxButtonEdit.ButtonClick event. By design, if the server-side Click event is handled, a postback is sent regardless of the AutoPostBack property value. Thus, when you click ASPxButtonEdit, a postback is performed, and data set in the CellEditorInitialize event handler is lost.
To overcome this issue, I suggest that you apply the following modifications:
- Set the ASPxGridView.EnableCallBacks property to true;
- Set the ASPxButtonEdit.AutoPostBack property to false;
- Delete the ASPxButtonEdit.ButtonClick event handler.
If you wish to perform any server-side actions, use ASPxCallbackPanel, as it is described in the K18387 Knowledge Base article (The Concept of Callbacks).
Thanks,
Marion

    Show previous comments (2)
    DevExpress Support Team 14 years ago

      Hello Alex,
      Thank you for your clarification.
      We need time to investigate the issue in light of provided information. We will contact you once we have any results.
      Best regards,
      Vladimir

      DevExpress Support Team 13 years ago

        Hello Alex:
        I am afraid, I cannot reproduce these problems on my side.
        Attached is a text project. This project contains a set of default column editors in the EditFormTemplate container, which are filled with test data using the CellEditorInitialize event.
        The custom ASPxButtonEdit is filled in its Init event handler according to the following approach:
        The general technique of using the Init/Load event handler
        I am testing old and new values in the ASPxGridView's RowInserting and RowUpdating event handlers, and it seems that ASPxGridView returns correct values.
        The RowValidating event contains code that is currently commented. You can uncomment this code and test that invalid values are returned to editors even when validation fails.
        Would you please modify this project according to your scenario or provide your own example that illustrates the discussed errors?
        Thanks
        Kate.

          I've replaced built-in grid EditForm with my own popup form for editing and that solved all issues. Thanks.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.