如何清除asp.net中的错误 [英] how to clear error in asp.net
本文介绍了如何清除asp.net中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在我的网页中进行设计错误发生
I have designing in my web page The error are occur
''dataType'' argument cannot be null.
Parameter name: dataType
代码
code
private DataTable CreateDataTable()
{
DataTable dt = new DataTable();
dt.Columns.Add("Size", System.Type.GetType("System.String"));
dt.Columns.Add("SizeID", System.Type.GetType("System.Int64"));
(_Error) dt.Columns.Add("Lamination", System.Type.GetType("System.Strings"));
dt.Columns.Add("Amount", System.Type.GetType("System.Int64"));
dt.Columns.Add("Noofcopies", System.Type.GetType("System.Int64"));
dt.Columns.Add("Total", System.Type.GetType("System.Int64"));
return dt;
}
推荐答案
乍一看:没有这样的类型System.Strings
.
问题解决了.
但是现在,让我们看看您是如何产生此问题以及如何避免它的.这是非常糟糕的编码:System.Type.GetType("System.String")
,因为您正在使用立即数字符串常量作为参数.如果您输错任何内容会怎样?编译器不会帮助您检测错误.当存在体面的方法时为什么要这样做?而是使用:
From the first glance: there is not such typeSystem.Strings
.
Problem solved.
But now, let''s see how did you create this problem and how to avoid it. This is extremely bad coding:System.Type.GetType("System.String")
, because you''re using immediate string constants for argument. What happens if you mistype anything? Compiler won''t help you to detect a bug. Why doing it when a decent method exist? Instead, use:
//for example:
System.Type myType = typeof(System.String);
问题已解决.
别惹麻烦!
祝你好运,
Problem prevented.
Don''t get in trouble!
Good luck,
您的错误:System.Type.GetType("System.Strings)
使用System.Type.GetType("System.String")
Your mistake: System.Type.GetType("System.Strings")
UseSystem.Type.GetType("System.String")
查看错误行上指定的类型,您使用的是String而不是String(即extra)
Look at the type specified on the error line, you have Strings instead of String (i.e. extra s)
这篇关于如何清除asp.net中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文