跟踪调试一下不就知道了。
你说CheckBoxList里面有9个CheckBox,但是你的代码里面j是循环了10次的,没出错?
不知道VB.NET的自动转换功能有多强大,但是建议还是把
check = DataGrid1.Items(i).Cells(1).FindControl("check1")
修改成:
check = CType(DataGrid1.Items(i).Cells(1).FindControl("check1"),CheckBoxList)
你说CheckBoxList里面有9个CheckBox,但是你的代码里面j是循环了10次的,没出错?
不知道VB.NET的自动转换功能有多强大,但是建议还是把
check = DataGrid1.Items(i).Cells(1).FindControl("check1")
修改成:
check = CType(DataGrid1.Items(i).Cells(1).FindControl("check1"),CheckBoxList)
解决方案 »
- 截取字符串
- 高分求教,网页的头部怎么在火狐浏览器和IE7中显示的位置不对呢?在IE6.0下正常
- 请教用asp.net作一个群发邮件功能
- 两个表关联查询后,绑定到Datagrid,但绑定结果不正确。如何解决?
- 输出显示数据库日期字段值问题!-----在线等!
- 求助,为什么一直提示错误
- 我想为单独的aspx页面拒绝授权的话应该怎么写?
- 自己开发的aspnet程序,浏览时出现“值不能为空。参数名:path2 “的错误,这是怎么回事?
- asp.net(c#)如何从sql数据库中提取数据并且按照字段名生成一个xml文件。。。。。
- 這次將關鍵的代碼貼出,請各位指教
- 关于DataList分页问题
- 一个存储过程问题,存储过程高手帮忙
c#代码string sql="delete from t_CarRegister where cLicense is null ";
foreach(DataGridItem dgi in DataGrid1.Items)
{
CheckBox cb=(CheckBox)(dgi.Cells[0].Controls[1]);
if (cb.Checked==true)
{
int i=dgi.ItemIndex;
string License=DataGrid1.DataKeys[i].ToString();
sql+=" or cLicense='"+License+"'";
}
}
我也将它转换了,但是还是这样的。我调试过,
If check.Items(j).Selected Then
qx += check.Items(j).Value
End If
中的qx += check.Items(j).Value根本就没执行,每次都跳出来了,是什么原因?
你想遍历datagrid上的所有checkboxlist但你的代码0~9并不是在一个checkboxlist里而是每一个的CHECK1.items[0]当然不会进入循环去累加了
用DataGridItem int qx=0;
foreach(DataGridItem dgi in DataGrid1.Items)
{
CheckBoxList cb=(CheckBoxList)(dgi.Cells[0].Controls[1]);
if (cb.Items[0].Selected)
{
qx+=cb.Items[0].Value; }
}