I have one grid with bound columns and one clientselectcolumn(checkbox).
Now when I check any checkbox, my grid data is updated in database using a stored procedure. It was working fine.
The issue is when I check any of checkbox, it updates all rows data, and not just the checked ones.
Following is the VB code:
Private Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim item As GridDataItem = DirectCast(GD_APay.Items(0), GridDataItem)
For Each item In GD_APay.Items
Dim chkbx As CheckBox = DirectCast(item("chkcolumn").Controls(0), CheckBox)
Dim str0 As String = item("School_number").Text.Trim
Dim str1 As String = item("JOBR_VENDOR_NOUN").Text.Trim
Dim str2 As String = item("Invoice_Date").Text.Trim
Dim str3 As String = item("Invoice_Number").Text.Trim
Dim str4 As String = item("OrderAmount").Text.Trim
Dim str5 As String = item("Invoice_Amt").Text.Trim
Dim str6 As String = item("ExceptionsFlag").Text.Trim
Dim con As New SqlConnection(ConfigurationManager.ConnectionStrings("FConnectionString").ConnectionString)
Dim cmd As New SqlCommand("P_FN_AP_SetInvoiceApprove", con)
If (chkbx.Checked = True) Then
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("@School_number", System.Data.SqlDbType.VarChar)
cmd.Parameters("@School_number").Value = str0
cmd.Parameters.Add("@JOBR_VENDOR_NOUN", System.Data.SqlDbType.VarChar)
cmd.Parameters("@JOBR_VENDOR_NOUN").Value = str1
cmd.Parameters.Add("@Invoice_Date", System.Data.SqlDbType.DateTime)
cmd.Parameters("@Invoice_Date").Value = str2
cmd.Parameters.Add("@Invoice_Number", System.Data.SqlDbType.VarChar)
cmd.Parameters("@Invoice_Number").Value = str3
cmd.Parameters.Add("@OrderAmount", System.Data.SqlDbType.Decimal)
cmd.Parameters("@OrderAmount").Value = str4
cmd.Parameters.Add("@Invoice_Amt", System.Data.SqlDbType.Decimal)
cmd.Parameters("@Invoice_Amt").Value = str5
cmd.Parameters.Add("@ExceptionsFlag", System.Data.SqlDbType.VarChar)
cmd.Parameters("@ExceptionsFlag").Value = str6
con.Open()
cmd.ExecuteNonQuery()
con.Close()
End If
Next
End Sub