Click to See Complete Forum and Search --> : Accessing array objects in sql statement


grunners
06-06-2010, 03:54 PM
Hi

I have a gridview control that displays expenses claims received from clients. I have a template field that contains a checkbox - if this is ticked, a value from the gridview is added to a variable and this is outputted to a label control.

What I then want to do is to update the database according to which roww has been ticked. I have so far the following code that adds each value to an array, which I was then hoping to access in the sql query i.e. Update table set value = value where id = (id's added to array)....hope that makes sense.

Code as follows - so far I'm just displaying the count of values in the array to make sure they are actually being added:

Protected Sub ProfessionalFeesCheckBox_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs)

Dim headerchkbox As CheckBox = ProfessionalFeesGridView.HeaderRow.FindControl("ProfessionalFeesHeaderCheckBox")
Dim PFid As New ArrayList

For Each row As GridViewRow In ProfessionalFeesGridView.Rows
Dim chkbox As CheckBox = row.FindControl("ProfessionalFeesCheckBox")
Dim selectedProfessionalFeesNumber As Decimal = ProfessionalFeesGridView.DataKeys(row.RowIndex).Value
Dim selectedProfessionalFeesID As Integer = ProfessionalFeesGridView.DataKeys(row.RowIndex).Item(1)

If chkbox.Checked Then
totalProfessionalFeesNumber = totalProfessionalFeesNumber + selectedProfessionalFeesNumber
PFid.Add(selectedProfessionalFeesID)
Else
headerchkbox.Checked = False
End If
Next
lblProfessionalFeesID.Text = PFid.Count

lblProfessionalFeesNumber.Text = totalProfessionalFeesNumber
lblSummaryProfessionalFees.Text = totalProfessionalFeesNumber

End Sub

Thanks