I am having an issue with no values being populated in the OldValues of ASPxDataValidationEventArgs.
When I run through the code the first validation occurs as a result of performing a DoRowValidation(). When the validation routine runs, both OldValues and NewValues are populated correctly. The process continues and when the validation routine is run again, as a result of the database update, the NewValues are populated but the OldValues aren't. From everything I have read in the support center, this is not possible but I have included a zip file which contains both the aspx and aspx.vb files as well as a Word doc with screen shots showing the first and second passes through the validation routine.
I have debugged it everywhich way I know how but cannot determine why the OldValues are not populated.
Any suggestions would be welcome.
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.
Hello Stephen,
Thank you for sending the page's markup and code to me. I've created a test project based on the provided sources and examined it. However, the e.NewValues and e.OldValues collections of the RowValidating event handler contain correct values (see the attached video).
The ASPxGridView's RowValidating event is automatically raised when a row is about to be updated, and allows you to specify whether its data is valid. Therefore, it's unnecessary to call the ASPxGridView's DoRowValidation method in the ASPxGridView's StartRowEditing event handler, because the default new ASPxGridView's DataRow doesn't contain the initial values (except the case when the initial values have been initialized via the ASPxGridView's InitNewRow event handler).
Could you please check how the attached project works? If it works well, please try to modify it to reproduce this issue and send the project back. We will do our best to help you.
Regards,
Mike
Mike,
Thanks for the sample and the video. Unfortunately, your sample works just as I would expect it to and since I don't know why mine does not work, I am unable to modify your sample to not work. I am not sure what is happening to the e.OldValues but even after removing the DoRowValidation from the StartRowEditing event, I still do not get values in e.OldValues. What other things can effect the e.OldValues? I can only presume I am doing something to wipe them out.
I guess the part that I don't follow is your statement "because the default new ASPxGridView's DataRow doesn't contain the initial values (except the case when the initial values have been initialized via the ASPxGridView's InitNewRow event handler)."
Are you saying the datarow is actually a "new" data row and therefore doesn't have initial values, even though this is an update event? (see I told you I didn't follow it)
Hello Stephen,
The described behavior (e.OldValues is null on validation) is strange, and we need a simple running project, illustrating this glitch, for more detailed research. If it is possible, please provide it.
Thanks,
Marion
Hello Marion,
After tearing apart my code, I have come to the conclusion that it has something to do with the fact that these columns are in EditItemTemplates. If I look at other columns which are not in EditItemTemplates, both e.OldValues and e.NewValues are populated.
Since the example provided does not contain a key value to another table I am unable to make this change. Before I rewrite the sample, is there something about EditITemTemplates which would prevent the values from being populated?
Regards,
Stephen
Hello Stephen,
Thanks for the additional information. On having examined your markup, I see that not all of the controls inside the EditItemTemplate container have the Value property. To populate the e.OldValues / e.NewValues, you should set the Value property by using the DataBinder Class:
Value='<%# Bind("SomeField") %>'
To learn more, please see:
ASP.NET data binding overview
Thanks,
Marion
Marion,
Thank you for looking into my markup, however one of the columns that I am most concerned with (Premise) does indeed have the Value property.
<dx:GridViewDataComboBoxColumn Caption="<%$ Resources:RZAgro, Premise %>" FieldName="id_Premise"
VisibleIndex="1">
<PropertiesComboBox DataSourceID="sdsPremises" TextField="dt_NameEn" ValueField="pk">
<ValidationSettings SetFocusOnError="True">
<RequiredField ErrorText="Please Select a valid value" IsRequired="True" />
</ValidationSettings>
</PropertiesComboBox>
<EditItemTemplate>
<dx:ASPxComboBox ID="cbProd" runat="server" DataSourceID="sdsPremises" TextField="dt_NameEn"
ValueField="pk" Value='<%# Bind("id_Premise") %>' AutoPostBack="True" OnSelectedIndexChanged="Prod_SelectedIndexChanged"
ValueType="System.Int32" ClientIDMode="AutoID"
CssFilePath="~/App_Themes/Office2003Blue/{0}/styles.css"
CssPostfix="Office2003Blue"
SpriteCssFilePath="~/App_Themes/Office2003Blue/{0}/sprite.css">
<LoadingPanelImage Url="~/App_Themes/Office2003Blue/Web/Loading.gif">
</LoadingPanelImage>
<ButtonStyle Width="13px">
</ButtonStyle>
</dx:ASPxComboBox>
</EditItemTemplate>
</dx:GridViewDataComboBoxColumn>
and it is set with the Bind: Value='<%# Bind("id_Premise") %>'
Is there something else that I need to do to access it inside an EditItemTemplate?
Regards,
Stephen
Hello Stephen,
Thank you for the clarification. Yes, I've reproduced the issue, and it looks like a bug. Therefore, I've decided to convert it to a bug issue and forwarded it to our developers for a detailed investigation. Sorry for a possible delay.
Thanks,
Marion
Public patch applied - issue corrected