RadGridview - Data Exception 'Column' does not allow nulls (RadGridview 2023.1.314.40.)

1 Answer 179 Views
GridView
Raj
Top achievements
Rank 1
Iron
Iron
Raj asked on 02 Jun 2023, 10:51 AM

Hi Team,

While inserting a new row in the radgridview, we are getting an error (Data Exception 'Column' does not allow nulls) in RadGridview 2023.1.314.40.

Except first 2 parameters the remaining params are throwing an error. Please refer the attached screenshot and code block below . Could you please help to solve this issue?

Note: Its working fine in Telerik.WinControls.GridView.dll 2013.3.1127.40

private void BtnInsertNPAPrice_Click(object sender, EventArgs e)
{
   try
   {
	   if (GridView.Rows.Count > 0)
	   {
		   if (GridView.DataSource != null && ((DataTable)GridView.DataSource).Rows.Count > 0)
		   {				 
			   this.GridView.Rows.Add("Test", "875", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);										 
		   }
	   }                  
   }
   catch (Exception ex)
   {
	  RadMessageBox.Show(ex.Message, Common.ErrorMsgHeader, MessageBoxButtons.OK, RadMessageIcon.Error);
   }
}

Thanks

Rajkannan

1 Answer, 1 is accepted

Sort by
1
Dess | Tech Support Engineer, Principal
Telerik team
answered on 02 Jun 2023, 11:42 AM

Hello, Raj,

According to the provided information and the error message you are facing, it seems that the specific column doesn't allow null values. Usually, there is a constraint in the column from the applied DataSource collection.

RadGridView offers the DataError event for handling such cases. The DataError event fires when an error on the DataSource side occurs, e.g. ConstraintException. It is not expected to keep the editor opened while a valid value is entered. It is just enough to subscribe to the DataError event and leave the event handler empty and the constraint error message (or another data error) wouldn't be shown to the end user. If you decide to notify the user for the incorrect data, you can show a message.

Please give this approach a try and see how it would work on your end.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
GridView
Asked by
Raj
Top achievements
Rank 1
Iron
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or