在我之前的帖子 中,我使用 javascript 来检查一些工作正常的复选框。但是我有一个按钮,可以将一些记录放入数据库。使用以下代码,复选框是否被选中并不重要,它总是给我错误。
bool first = true;
bool _IsPhone = false;
bool _IsLotus = false;
bool _IsRelationship = false;
bool _IsAdmin = false;
string _Country;
foreach (GridViewRow row in CountryAccessGrid.Rows)
{
CheckBox ch = ((CheckBox)row.FindControl("chkPhones"));
_Country = ((Label)row.FindControl("lblCountryShort")).Text;
_IsPhone = ((CheckBox)row.FindControl("chkPhones")).Checked;
_IsLotus = ((CheckBox)row.FindControl("chkLotus")).Checked;
_IsRelationship = ((CheckBox)row.FindControl("chkRelationship")).Checked;
_IsAdmin = ((CheckBox)row.FindControl("chkIsAdmin")).Checked;
if (_IsPhone == true || _IsLotus == true || _IsRelationship == true || _IsRelationship == true || _IsAdmin == true)
{
cntr = cntr + 1;
if (!first)
{
insertaccess += " UNION ALL ";
}
insertaccess += " SELECT " + _UserID + ", '" + _Country + "', " + _IsPhone + ", " + _IsLotus + ", " + _IsRelationship + ", " + _IsAdmin;
first = false;
}
}
请问如何获得复选框的状态?