我有一个datagrid
,我想将选择列存储到array list
。
然后,当用户点击array list
时,我想将submit
发送到数据库中存储。
Private alBackUp As New System.Collections.ArrayList()
Private Sub CancelUserUpdate()
Dim backuplist As String = String.Empty
For i As Integer = 0 To backuplist.Rows.Count - 1
backuplist = dgvBackup.CurrentRow.Index
Dim col1 As String = dgvBackup.Item("col1", i).Value
Dim col2 As String = dgvBackup.Item("col2", i).Value
Dim col3 As String = dgvBackup.Item("col3", i).Value
Dim col4 As String = dgvBackup.Item("col3", i).Value
alBackUp.Add(col1,col2,col3,col4)
Next
End Sub
当用户点击提交按钮时,将项目发送到存储在datebase
中Private Sub CancelUserUpdate()
For i As Integer = 0 To alBackUp.Rows.Count - 1
CancelUpdate(alBackUp)
Next
End Sub
Public Shared Function CancelUpdate(ByVal col1 As String, ByVal col2 As String, ByVal col3 As String, ByVal col4 As String) As DataTable
.....
.....
.....
End Function
答案 0 :(得分:0)
首先,这一行:For i As Integer = 0 To backuplist.Rows.Count - 1
看起来应该是For i As Integer = 0 To dgvBackup.Rows.Count - 1
,因为'backuplist'被定义为'String'而不是'DataGridView',但这应该是一个明显的错误显示在您的代码中。
其次,此backuplist = dgvBackup.CurrentRow.Index
也应该向您显示错误,因为Index
是“整数”类型,backuplist
被声明为类型String
。
然后你再次使用alBackup
,好像它是DataGridView
行中的alBackUp.Rows.Count
:Array
但它是{{1}}所以这应该是'alBackup.GetUpperBound (0)'
因此,您发布的代码充满了错误,请先尝试解决这些问题,然后再继续查看实际逻辑。