Ticket T365412
Visible to All Users

XtraGrid with comboBox column doesn't save value in grid

created 9 years ago

Hello,

I have problem on xtragrid with repositoryItemComboBox column.
I have two tables in grid I load rows from stored procedure, I want load list to comboBox from second stored procedure and use values in rows.
For this moment all works fine, but when I change row control doesn't remember selected value.
I read a lot of topic with similar problems but I didn't find solutions. I had similar problem with this when I wanted use different possible values in comboBox, then I used many instances of repositoryItemComboBox but I'm sure that there is more simple way if set of possible rows is the same for each row in xtraGrid.
I prepared sample solutions with SQL scripts which demonstrate this problem on sample data.

Answers approved by DevExpress Support

created 9 years ago

Hello Krzysztof,
Thank you for the provided sample. I reviewed it and found the cause of the issue. It occurs since the "newCode" column is not bound to any field in your data source. Thus, value cannot be stored when you change it in the in-place ComboBoxEdit.
Would you please clarify whether this column should be bound or not? If the first case, set the FieldName to any existing field in your data source table. If the second one, use Unbound Columns. Please review the Unbound Columns article for more information in this regard.
If this information doesn't help you resolve the issue, describe your scenario in greater detail. It will help us find an appropriate solution for you.

    Show previous comments (1)
    Sasha (DevExpress Support) 9 years ago

      Hello Krzysztof,
      Thanks for the provided sample. The issue occurs since the "id_s" column is read-only.
      To overcome this issue, make it editable by setting the ReadOnly property to false:

      C#
      public static DataTable GetList() { try { SqlConnection conn = new SqlConnection("Server=(local);Database=testdb;Trusted_Connection=True;"); conn.Open(); DataTable dt = new DataTable(); using(SqlCommand command = new System.Data.SqlClient.SqlCommand("dbo.sp_getlist", conn)) { command.CommandType = System.Data.CommandType.StoredProcedure; dt.Load(command.ExecuteReader()); } conn.Close(); conn.Dispose(); dt.Columns[0].ReadOnly = false; return dt; } catch(Exception e) { if(!string.IsNullOrEmpty(e.Message) && e.Message != " ") MessageBox.Show(e.Message); return null; } }

      Please try this approach and let me know if it is helpful.

      KS KS
      Krzysztof Stachyra 9 years ago

        Thanks Sasha, it looks good :)

        Sasha (DevExpress Support) 9 years ago

          Hi,
          I am happy to hear that you have found my assistance helpful.
          Please feel free to contact us in case of any difficulty.

          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.