2011-08-07 35 views
0

这行代码引用Gridview中的复选框,我如何将复选框1或-1的值(我认为是选中还是取消选中)指定给变量我可以针对它运行一个if语句,并将其更改为True或False?帮助将Gridview复选框分配给变量

dt.Rows(row.DataItemIndex)("DisplayString") = (CType((row.Cells(3).Controls(0)), CheckBox)).Checked 

回答

1

试试这个:

Dim checkBox1 as CheckBox = CType((row.Cells(3).Controls(0)), CheckBox) 
checkBox1.Checked = True 

编辑

我不知道我完全理解它是什么你想干什么?

你是试图根据值1或-1检查/取消选中CheckBox吗?

请您详细说明一下吗?

0

这是为我工作的解决方案。我需要阅读的复选框的条件/状态,如果对结果语句中使用的....

dt.Rows(row.DataItemIndex)("DisplayString") = (CType((row.Cells(1).Controls(0)), CheckBox)).Checked 

Dim CB As CheckBox = CType((row.Cells(1).Controls(0)), CheckBox) 
value = CB.Checked 

现在我可以在我的if语句用“价值”。