【发布时间】:2019-02-02 01:38:28
【问题描述】:
我正在尝试使用以下代码来检查至少一个复选框已被选中。如果选中了一个复选框,那么该行中的一个文本框就会有一些值。但是当我使用Cells时它给了我一个错误@
错误是 Gridview 不包含“Cells”的定义,并且找不到接受 GridView 类型的第一个参数的扩展方法“Cells”。
我不知道为什么它给了我这个错误。
private Boolean checkIfChecked()
{
int check = 0;
foreach (GridView row in gvPizzaOrder.Rows)
{
CheckBox chk = row.Cells[0].Controls[1] as CheckBox;
if (chk.Checked)
{
check++;
TextBox quantity = row.Cells[3].Text as TextBox;
if (quantity.Text == "")
{
return false;
}
}
}//end forreach
if (check == 0)
{
return false;
}
else
return true;
}//end checkIfChecked
【问题讨论】: