I assign the checkbox each row with specific values from field "pid" retrieved from database. Then when submit button is clicked. I loop through each row to check if checkbox is selected. If selected, then update the table where pid = pid from checkbox value. But somehow my code not working :P Please help:
Code:
<asp:TemplateColumn Visible="False" HeaderText="PeoplewiseID">
							<ItemTemplate>
								<asp:Label ID="lblPeoplewiseID" Text='<%# DataBinder.Eval(Container.DataItem, "Peoplewise_ID") %>' Runat="server" />
							</ItemTemplate>
						</asp:TemplateColumn>
the code behind....
Code:
Public Sub UpdatePayment(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim update As New EventDetailBO
        Dim dgItem As DataGridItem
        Dim chkSelected As CheckBox
        Dim pplwiseID As Integer
        Dim strPID As String
        
        For Each dgItem In dgNotPaid.Items
            chkSelected = dgItem.FindControl("chkPayment")
            If chkSelected.Checked Then
                strPID = CType(dgItem.FindControl("lblPeoplewiseID"), Label).Text
                pplwiseID = pplwiseID.Parse(strPID)
                'pplwiseID = (CType(dgItem.FindControl("chkPayment"), CheckBox).Checked) * -1
                update.updatePayment(pplwiseID)
                lblSelected.Text += pplwiseID.ToString()
                lblSelected.Text += "<br>"
            End If
        Next

    End Sub
The update statement...not sure if it's correct, the "sp_updatePayment" is a stored procedure:
Code:
Public Function updatePay(ByVal pplwise As Integer) As Integer
        Dim strpplwise As String
        Dim strConn As String = "workstation id=MYD525MG1S;packet size=4096;user id=sa;data source=MYD225MG1S;pers" & _
                        "ist security info=False;initial catalog=ems"
        Dim conn As New SqlConnection(strConn)
        Dim pplwiseID As New SqlParameter("@pplwsID", SqlDbType.Int)
        pplwiseID.Direction = ParameterDirection.Input
        pplwiseID.Value = pplwise
        Dim objCmd As SqlCommand = New SqlCommand("sp_updatePayment", conn)
        conn.Open()
        objCmd.CommandType = CommandType.StoredProcedure
        objCmd.Parameters.Add(pplwiseID)
        objCmd.ExecuteNonQuery()
        conn.Close()
        Return pplwise
    End Function