Sunday, February 1, 2009

Pick UP GRIDview values on BUTTON CLICK in VB.net

Protected Sub btnactive_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Try
Dim strPid As String
Dim varCount As Int32 = 0
While varCount < grdexistingproduct.Rows.Count
Dim grdRow As GridViewRow = grdexistingproduct.Rows(varCount)
Dim boolIschecked As Boolean = CType(grdRow.FindControl("chkSelect"), CheckBox).Checked
If boolIschecked Then
strPid = grdexistingproduct.Rows(varCount).Cells(3).Text
cmd.CommandText = "update tblprod set active='1' where pid='" & strPid & "'"
cmd.Connection = con.createConnection(Session("site"))
cmd.ExecuteNonQuery()
cmd.Dispose()
Else
strPid = grdexistingproduct.Rows(varCount).Cells(3).Text
cmd.CommandText = "update tblprod set active='0' where pid='" & strPid & "'"
cmd.Connection = con.createConnection(Session("site"))
cmd.ExecuteNonQuery()
cmd.Dispose()
End If
varCount = varCount + 1
End While
'Bind_Productsdeactivate()
'lblRes.Text = "Modifications are being saved"
Catch ex As Exception
'lblRes.Text = ex.Message
End Try
End Sub

No comments:

Post a Comment