Datagrid entry does not populate dropdown with foreign ids

I'm creating a Radzen demo for my company as a possible data entry system.
I've connected our ms sql server DB as a data source and have successfully created the CRUD pages I need. However, when I try to add an entry in the data grid, I expected the foreign keys to populate with ids in the entry dropdown.

I've done some research on my own and everything I've found requires some multi step coding change.
Simply put, how can I populate this dropdown with the correct foreign ids?

image

Hi @elys_k,

Can you elaborate what you expected to happen? Do you expect a value to be selected initially in the dropdown?

Yes, If I have two tables, one with primary key A and another table with foreign key F that references primary key A from the first table, I expected the data grid drop down to populate with the possible values of Primary key A, such that I can create new entries in the second table that satisfy the constraint.

How can I accomplish this?

I am not sure I understand your setup. Do you want cascading dropdowns? The first dropdown to filter the second one?

Not cascading.

If I have a Colors table with ColorID and Color Name
and a Fruits table with FruitID ColorID etc, where ColorID is a foreign key constraint and references Colors.

I'd like to be able to show table Fruits in a datagrid and be able to create new entries in the Fruits table by selecting the referenced values from Colors in a dropdown. Currently, the "Fruits" table has a dropdown for ColorID but no values are populating, thus I cannot create new entries in Fruits because ColorID cannot be null, and does not present the ability to select or enter a value.

Did you use the default inline editing page template? It should create the necessary code to populate the dropdowns in the Page load event. If you haven't you should data-bind the dropdowns (set their Data property).

I used the default inline editing page template. Did not automatically populate the drop downs, but was able to identify it as a foreign key. I can't seem to see where to databind the drop down portion. Where can I find this? Thank you for your help!

When you use the Grid Inline edit page wizard you need to check the related entities (in this case Order and Product):


Then Radzen will generate code that loads the available items and store them in page properties:

The dropdown components in the edit template have their Data property set to those properties:

I suggest you check if you have similar code in the Load event of the page and whether the Data property of the dropdowns is set.