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:
- if (!dtMain.Columns.Contains("OLDOUTNO"))
- {
- dtMain.Columns.Add("OLDOUTNO", typeof(string));
- }
2. If you want to remove the "OLDOUTNO" column field after you add it, you can use the following methods:
- if (dtMain.Columns.Contains("OLDOUTNO"))
- {
- dtMain.Columns.Remove("OLDOUTNO");
- }
complete! good luck !
No comments:
Post a Comment
Note: only a member of this blog may post a comment.