Ticket Q350500
Visible to All Users

ASPxGridView - e.OldValues returns null for a combobox column

created 13 years ago

Hi i have a problem with the gridview in edit mode.
I have loaded the gridview from multiple datasources (some are just lookup tables)
But when i click edit on a row, and not change a certain value and try to access it using e.OldValues["columnName"] it gives me the string name and not the lookup ID, but if i change that data to something else then it works and gives me the ID instead of the name. Code below:
Load data from lookuptable and fill the grid with value=ID and text=Produkt
<dx:GridViewDataComboBoxColumn FieldName="Scoring" VisibleIndex="5">
                <PropertiesComboBox Spacing="0" ValueType="System.Int32" DataSourceID="dsScoringType" ValueField="id" TextField="Produkt">
                </PropertiesComboBox>
</dx:GridViewDataComboBoxColumn>
 The SQLDataSource that loads the lookup tables information
 <asp:SqlDataSource ID="dsScoringType" runat="server"
        ConnectionString="<%$ ConnectionStrings:halldbConnectionString %>"
        SelectCommand="SELECT [id], [Produkt] FROM [selScoringType]"
        OldValuesParameterFormatString="original_{0}">
</asp:SqlDataSource>
The GridViews RowUpdating event
protected void custGridview_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
{
            // If this hasent been changed the value will be a string with the name
            // If it has been changed though i get the correct data, that is the ID and not the name
            var scoringType = e.NewValues["Scoring"];
            var scoringType2 = e.OldValues["Scoring"];
}
Why is this behaving like this?

Show previous comments (2)

    Hi
    If i look at the following demo
    http://demos.devexpress.com/ASPxGridViewDemos/GridEditing/CascadingComboBoxes.aspx
    I see there is alot of code behind doing just this. Am i really supposed to write all this code for every combobox that has lookup tables values?

    DevExpress Support Team 13 years ago

      Hi Andreas,
      Thank you for sending us your sample. It seems that your SQL Server (700) is newer than mine (663), so I cannot use your database. However, I have created an in-memory datasource based on your data. I am afraid my attempts to reproduce the issue have been unsuccessful. Would you please check how the attached project operates? If it operates well, reproduce this issue using it and send the project back to us. Alternatively, you can provide your complete project. We will do our best to help you.
      In addition, I have noticed that you are using the Country string value to synchronize two database tables. By design, to make GridViewDataComboBoxColumn operate properly, the GridViewDataComboBoxColumn.FieldName and PropertiesComboBox.ValueField values should be equal, but not TextField. It is a common practice to use a number value for this purpose.
      Thanks,
      Marion

        I got the help i needed

        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.