這行代碼引用Gridview中的複選框,我如何將複選框1或-1的值(我認爲是選中還是取消選中)指定給變量我可以針對它運行一個if語句,並將其更改爲True或False?幫助將Gridview複選框分配給變量
dt.Rows(row.DataItemIndex)("DisplayString") = (CType((row.Cells(3).Controls(0)), CheckBox)).Checked
這行代碼引用Gridview中的複選框,我如何將複選框1或-1的值(我認爲是選中還是取消選中)指定給變量我可以針對它運行一個if語句,並將其更改爲True或False?幫助將Gridview複選框分配給變量
dt.Rows(row.DataItemIndex)("DisplayString") = (CType((row.Cells(3).Controls(0)), CheckBox)).Checked
試試這個:
Dim checkBox1 as CheckBox = CType((row.Cells(3).Controls(0)), CheckBox)
checkBox1.Checked = True
編輯
我不知道我完全理解它是什麼你想幹什麼?
你是試圖根據值1或-1檢查/取消選中CheckBox嗎?
請您詳細說明一下嗎?
這是爲我工作的解決方案。我需要閱讀的複選框的條件/狀態,如果對結果語句中使用的....
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語句用「價值」。