我有一个产品选项选择的网格视图(称为OptionChoicesGrid),其中包含各种字段,其中一个是名为" SkuMod。"的文本框字段。只有一个选项可能有一个空的SkuMod字段 - 其余必须包含一个值。我试图找出使用数组执行此检查的最佳方法,因为可以允许一个空字段。或者也许我不应该使用数组?任何建议都会很棒!
这是我现在正在建立的一项功能:
protected bool CheckSkuMod()
{
bool ValidMods = true;
OptionChoice opt; //opt.SkuModifier is used to check that particular choice
foreach (GridViewRow row in OptionChoicesGrid.Rows)
{
//build array here?
}
return ValidMods;
}
答案 0 :(得分:0)
if(OptionChoicesGrid.Rows.Count(r => string.IsNullOrEmpty(r.field) > 1){
validMods = false;
}