Thanks Sir nit_singh
Ive found the error, ive created another sub named BindGrid and thats what im calling on my editing events
<pre lang="vb">Protected Sub TPdataCCXXXXX_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles TPdataCCXXXXX.RowEditing
TPdataCCXXXXX.EditIndex = e.NewEditIndex
BindGrid()
End Sub
Protected Sub TPdataCCXXXXX_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles TPdataCCXXXXX.RowCancelingEdit
TPdataCCXXXXX.EditIndex = -1
BindGrid()
End Sub
Public Sub BindGrid()
If drpcc.Text = "CCXXXXX" Then
Dim strSQL As String
Dim connection As SqlClient.SqlConnection = New SqlClient.SqlConnection("Data Source=ML0003135586;Initial Catalog=TestSQL;Integrated Security=True")
strSQL = "SELECT [ID], [CourseTitle], [CourseCode], [Objectives], [Duration] FROM [tblTrainingPlan] WHERE ([CostCenter] = @CostCenter)"
connection.Open()
Dim myCommand As SqlClient.SqlCommand = New SqlClient.SqlCommand(strSQL, connection)
myCommand.Parameters.AddWithValue("@CostCenter", drpcc.Text)
TPdataCCXXXXX.DataSource = myCommand.ExecuteReader()
TPdataCCXXXXX.DataBind()
ElseIf drpcc.Text = "123" Then
Dim strSQL As String
Dim connection As SqlClient.SqlConnection = New SqlClient.SqlConnection("Data Source=ML0003135586;Initial Catalog=TestSQL;Integrated Security=True")
strSQL = "SELECT [ID], [CourseTitle], [CourseCode], [Objectives], [Duration] FROM [tblTrainingPlan] WHERE ([CostCenter] = @CostCenter)"
connection.Open()
Dim myCommand As SqlClient.SqlCommand = New SqlClient.SqlCommand(strSQL, connection)
myCommand.Parameters.AddWithValue("@CostCenter", drpcc.Text)
TPdataCCXXXXX.DataSource = myCommand.ExecuteReader()
TPdataCCXXXXX.DataBind()
End If
End Sub