0

I have a DataTable as a data source for a GridLookUpEdit.

  private void MachineTreeCellEdit(object sender, GetCustomNodeCellEditEventArgs e) {
     Contract.Assume(sender != null, "sender is null.");
     Contract.Assume(e != null, "e is null.");

     if (e.Node != null) {
        var element = e.Node.GetValue(0) as XElement;
        if (element == null) {
           // no element object
           return;
        }

        if (element.Name.LocalName == "host" && e.Column.Name == "machineViewGroups") {
           GridLookUpEdit lookup = new GridLookUpEdit();
           lookup.Properties.DisplayMember = "Name";
           lookup.Properties.ValueMember = "Name";
           lookup.Properties.DataSource = GetLookupDataSource(element);
           lookup.Properties.PopulateViewColumns();

           e.RepositoryItem = lookup.Properties;
        }
     }
  }

  private DataTable GetLookupDataSource(XElement element) {
     var configsTable = new DataTable("Configurations");
     configsTable.Columns.AddRange(new DataColumn[] { 
        new DataColumn("Name", typeof(string)),
        new DataColumn("Version", typeof(string))
     });

     var groupAncestor = element.Ancestors("group").First();
     var configOptions = Presenter.Repository.Root
                                  .Elements("group")
                                  .Where(el => el.Attribute("name").Value == groupAncestor.Attribute("name").Value)
                                  .SelectMany(el => el.Descendants("cfg"))
                                  .ToList();

     for (int option = 0; option < configOptions.Count; option++) {
        var newRow = configsTable.NewRow();
        newRow["Name"] = configOptions[option].Attribute("name").Value;
        newRow["Version"] = configOptions[option].Element("version").Value;
        configsTable.Rows.Add(newRow);
     }

     configsTable.AcceptChanges();

     return configsTable;
  }

Although I have a data table created with rows, why is the GridLookUpEdit always displaying [EditValue is null] instead of the data in the data table?

Additionally, when I click on the drop-down arrow, the pop-up does not display. That would tell me that the data source is empty. However, I validated the data table has data that I expect.

IAbstract
  • 19,551
  • 15
  • 98
  • 146
  • Why don't you contact DX directly? – Mikhail Apr 03 '13 at 18:15
  • That is the default for DevExpress controls when, quite specifically, the EditValue is null. you can change that message, but you are better off trying to figure out what the editValue is supposed to be, and _why_ the editvalue is null – Nevyn Apr 03 '13 at 18:29
  • @Mikhail: because I prefer StackOverflow. SO typically provides the first 1/2 to full page of links any time I seek help on a programming topic. :) – IAbstract Apr 03 '13 at 19:03
  • @Nevyn: edited to clarify what I'm after. :) – IAbstract Apr 03 '13 at 19:05
  • At the testing time, when you are seeing the message you are seeing, _What is the Actual EditValue of the Lookup?_ This is the important thing to check. Also important...when you open the lue, is the data you expect to see actually there, but its simply the DisplayMember itself that's telling you it is null? – Nevyn Apr 03 '13 at 19:12

0 Answers0