We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Null Foreign Key Field Being Returned To Controller As 0 When Adding New Row In Batch Edit Mode

Thread ID:





121606 Jan 7,2016 12:25 AM UTC Jan 7,2016 09:28 AM UTC ASP.NET MVC 1
Tags: Grid
Jeffrey Stone
Asked On January 7, 2016 12:25 AM UTC

I have a foreign key field column that is returning a value of 0 to the controller for newly created rows. However, a null is correctly returned if I update existing rows. How can I get a null value to be returned for new rows?

Here is the column declaration:
col.Field("TransferToBrokerageSubAccountId").ForeignKeyField("BrokerageSubAccountId").ForeignKeyValue("FullAccountName").DataSource(((IEnumerable<object>)ViewBag.SubAccounts)).HeaderText("Transfer To").Add();

I am using the grid in batch edit mode with the datasource configured as:
.Datasource(ds => ds.URL(@Url.Action("BatchDataSource", "AccountTransaction")).BatchURL(@Url.Action("BatchUpdate", "AccountTransaction")).Adaptor(AdaptorType.UrlAdaptor))

And the class that it is being put into is (with most fields omitted):

// class does not have any defined constructors
public class BrokerageAccountTransactionRow
    #region Properties and Indexers

    public decimal Amount { get; set; }
    public int BrokerageSubAccountId { get; set; }
    public int? TransferToBrokerageSubAccountId { get; set; }

Regards, Jeff

Gowthami V [Syncfusion]
Replied On January 7, 2016 09:28 AM UTC

Hi Jeff,

Thanks for using Syncfusion products.

We have analyzed your issue and we found that by default, for number type columns the default value is 0. So that only while adding new rows the value passed as 0.

We can resolve the issue by set “DefaultValue” property of the columns as empty string for the corresponding foreign key column as follows,

            .Datasource(ds => { ds.URL(Url.Action("BatchDataSource")).BatchURL(Url.Action("DetailUpdate")).Adaptor(AdaptorType.UrlAdaptor); })
. . . .
. . . .

.Columns(col =>

col.Field("EmployeeID").HeaderText("Employee Name").DefaultValue("").ForeignKeyField("EmployeeID")

. . . .

For your reference we have attached the sample (version below,


Refer to the below screenshot,

If we misunderstood your issue , share us the sample with the issue which will help to analyze the issue and provide you the response as early as possible.


Gowthami V.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon