SQL, C#, VB, .net, asp, JavaScript, you name it. Code samples, Error messages and stuff like that. Please add coments if you think I said something stupid :D or if you have a better idea ... or anything at all ...
Wednesday, February 24, 2010
How to check in C# if a DataRow is Empty. (nothing in any column)
I was hoping i find something like dr.isEmpty(), but there's nothing "this nice". So you do something plain like:
bool AreAllColumnsEmpty(DataRow dr) { if (dr == null) { return true; } else { foreach(var value in dr.ItemArray) { if (value != null) { if (value.ToString() != "") { return false; } } } return true; } }
No comments:
Post a Comment