GridForeignColumn dropdown and SfDataManager throws argument null exception
Below is a code snippet and controller method (ServerController) referenced by the data viewer.
<GridForeignColumn Field=@nameof(Config_Files.ServerId) HeaderText="Server" TValue="Config_Servers" ForeignKeyField="RecordId" ForeignKeyValue="Name">
<SfDataManager Url="@(Configuration["HostName"] + "/Server/GetFTPDropDown")" Adaptor="Adaptors.WebApiAdaptor"></SfDataManager>
</GridForeignColumn>
[HttpGet]
[Route("[action]")]
public async Task<object> GetFTPDropDown()
{
var getResponse = await _ftpService.GetFTPHostServers();
var hostServers = getResponse.Result;
var count = hostServers.Count();
var queryString = Request.Query;
if (queryString.Keys.Contains("$inlinecount"))
{
StringValues Skip;
StringValues Take;
int skip = (queryString.TryGetValue("$skip", out Skip)) ? Convert.ToInt32(Skip[0]) : 0;
int top = (queryString.TryGetValue("$top", out Take)) ? Convert.ToInt32(Take[0]) : count;
return new { items = hostServers.Skip(skip).Take(top), Count = count };
}
else
{
return hostServers;
}
}
The model follows
public Config_Files()
{
Config_PostingFiles_Elements = new HashSet<Config_PostingFiles_Elements>();
}
The model is something like
[Key]
public int RecordId { get; set; }
[Required]
[StringLength(100)]
public string Name { get; set; }
public int? ServerId { get; set; }
[ForeignKey(nameof(FTPServerId))]
[InverseProperty(nameof(Config_Servers.Config_Files))]
[JsonIgnore]
public virtual Config_Servers FTPServer { get; set; }
We encountered an issue when the servers database table that holds does not contain any records. If there are no records in this table, the DataGrid that uses the foreign column referenced above will not render and an error in the console is thrown. One difference is develop and local environments throw different errors.
Is there anyway to handle the argument null exception within the datamanager of the foreign colum?. This application is running version 19.2.0.55.
Attachment: Untitled_2b23ddaf.png
Hi Jose,
Based on your query, we understand that you are encountering a null reference exception during the initial rendering of the DataGrid, specifically when the foreign key column is being bound. To assist you more effectively, we kindly request a few additional details from your end.
To proceed further, please provide the following information:
- Please let us know which adaptor you are using to render the DataGrid.
- Confirm us by updating your nuget package to the latest version, and specify whether the issue still exists from your end.
- Please provide a simple issue replicating sample from your end, so that we could assist you more effectively.
- Share us the entire Grid code snippet with all your customization.
The above-requested details will be very helpful for us to validate the reported query at our end and provide the solution as early as possible
Regards,
Sanjay Kumar Suresh
- 1 Reply
- 2 Participants
-
JO Jose
- Jan 29, 2026 09:37 PM UTC
- Jan 30, 2026 01:52 PM UTC