Hello
I want to updated recoreds accroding to all the checkbox which is checked on page1 page 2 and so on
But right not only first page records get updated not from the all the pages
Can you please suggest me how to read the checkbox values from all the pages which has all the checkbox checkes ?
My code is
I have one update button
After clicking on update button all the values are getting updated
in database and according to that my Gridview will get updated
Protected Sub Update_Click(sender As Object, e As System.EventArgs) Handles Update.Click
For Each row As GridViewRow In Gridview1.Rows
Dim ChkBoxCell As CheckBox = CType(row.FindControl("chkStatus"), CheckBox)
If ChkBoxCell IsNot Nothing Then
If ChkBoxCell.Checked = True Then
Dim Val_EmpID As String = CType(row.Cells(1).Text, String)
If Val_EmpID <> "" Then
Get_AllValuesfromViews(Val_EmpID)
End If
End If
End If
Next
Update.Visible = True
Gridview1.DataSourceID = Nothing
Gridview1.DataSource = Nothing
Binddata()
Gridview1.DataBind()
Gridview1.Visible = True
End Sub
Protected Sub Get_AllValuesfromViews(ByRef EmpID As String)
Get_EMPDEPT(EMPID, EMPDEPT)
Dim myconn1 As SqlConnection = New SqlConnection(ConfigurationManager.AppSettings("connString"))
myconn1.Open()
Dim Sqlreader As SqlDataReader
Dim sqlcmd As SqlCommand = New SqlCommand()
With sqlcmd
.CommandType = CommandType.StoredProcedure
.CommandText = "proc_Get_ValuesWithEmpID"
.Connection = myconn1
.Parameters.AddWithValue("@EmpID", EmpID)
Sqlreader = .ExecuteReader
End With
Dim Val_lYear As String = ""
Dim Val_EmpID As String = ""
Dim val_CurrYr_EMP As String = ""
Dim val_NextYr_EMP As String = ""
Dim val_TransitionedTo_DEPT As String = ""
Try
While Sqlreader.Read()
If Sqlreader IsNot Nothing Then
Val_Year = Sqlreader.Item("Year")
Val_EmpID = Sqlreader.Item("EmpID")
val_CurrYr_EMP = Sqlreader.Item("CurrYr_Emp")
val_NextYr_EMP = Sqlreader.Item("NextYr_EMP")
val_TransitionedTo_DEPT = Sqlreader.Item("TransitionedTo_dept")
If Val_EmpID IsNot Nothing Then
UpdatetableWithInsertcommand(Val_Year, Val_EmpID, val_CurrYr_EMP, val_NextYr_EMP, val_TransitionedTo_dept)
End If
End If
End While
Catch ex As Exception
myconn1.Close()
myconn1.Dispose()
Sqlreader.Close()
sqlcmd.Dispose()
End Try
myconn1.Close()
myconn1.Dispose()
Sqlreader.Close()
sqlcmd.Dispose()
End Sub
Protected Sub UpdatetableWithInsertcommand(ByRef Val_SchoolYear As String, ByRef Val_EmpID As String, ByRef val_CurrYr_School As String, ByRef val_NextYr_School As String, ByRef val_TransitionedTo_School As String)
Dim myUserInfo As User_Info = Session("UI")
Dim Date_time As String = System.DateTime.Now
Dim myconn1 As SqlConnection = New SqlConnection(ConfigurationManager.AppSettings("connString"))
Dim sqlcmd As SqlCommand = New SqlCommand
Try
myconn1.Open()
Dim Query As String = " Insert into SASA_PreTransition_ReAssignmentsApproved ([Year],[EmpID],[CurrYr_EMP], [NextYr_EMP] ,[TransitionedTo_DEPT], Approved, Comment, ApprovedBy, ApprovedDate ) Values ('" & Val_Year & "' ,'" & Val_EmpID & "', '" & val_CurrYr_EMP & "' , '" & val_NextYr_EMP & "','" & val_TransitionedTo_DEPT & "','1','Approved' , '" & myUserInfo.Name & "' ,'" & Date_time & "' )"
sqlcmd = New SqlCommand(Query, myconn1)
sqlcmd.ExecuteNonQuery()
Catch ex As Exception
myconn1.Close()
myconn1.Dispose()
sqlcmd.Dispose()
Finally
myconn1.Close()
myconn1.Dispose()
sqlcmd.Dispose()
End Try
End Sub