W3Schools Learner's Blog

W3Schools Programming knowledge summary website

div

5/07/2018

An unhandled exception of type 'System.ArgumentException' occurred in System.Data.dll

C# i am getting exception :
An unhandled exception of type 'System.ArgumentException' occurred in System.Data.dll
Column "OLDOUTNO" does not belong to table
Solution :
1. Manually add the column field to the DataTable object of Gridview, dtMain in this case is datatable object, The method is as follows:
  1. if (!dtMain.Columns.Contains("OLDOUTNO"))
  2. {
  3. dtMain.Columns.Add("OLDOUTNO", typeof(string));
  4. }
2. If you want to remove the "OLDOUTNO" column field after you add it, you can use the following methods:
  1. if (dtMain.Columns.Contains("OLDOUTNO"))
  2. {
  3. dtMain.Columns.Remove("OLDOUTNO");
  4. }
complete! good luck !

No comments:

Post a Comment

Note: only a member of this blog may post a comment.