解決辦法:
1.if (dtedit.Rows[k][i] == DBNull.Value)
num = 0;
else
num = Convert.ToInt32(dtedit.Rows[k][i]);
2.在讀取數據庫數據時判斷.如"Select IsNull(score,0) from score" 先把為null的數據表示為0
3. public static int ParseInt(object obj)
{
int reInt = -1;
if (obj != null)
int.TryParse(obj.ToString(), out reInt);
return reInt;
}