<pre lang="vb">Protected Sub Gridview1_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridView1.RowUpdating
Dim row As GridViewRow = GridView1.Rows(e.RowIndex)
Dim txtID As TextBox = row.FindControl("txtID")
'Dim txtCourseTitle As TextBox = row.FindControl("txtCourseTitle")
Dim txtCourseCode As TextBox = row.FindControl("txtCourseCode")
Dim txtObjectives As TextBox = row.FindControl("txtObjectives")
Dim txtDuration As TextBox = row.FindControl("txtDuration")
End Sub
Protected Sub Gridview1_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GridView1.RowEditing
GridView1.EditIndex = e.NewEditIndex
BindGrid()
End Sub
Protected Sub Gridview1_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GridView1.RowCancelingEdit
GridView1.EditIndex = -1
BindGrid()
End Sub
Public Sub BindGrid()
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]"
connection.Open()
Dim myCommand As SqlClient.SqlCommand = New SqlClient.SqlCommand(strSQL, connection)
GridView1.DataSource = myCommand.ExecuteReader()
GridView1.DataBind()
connection.Close()
End Sub