Imports System.Data

Partial Class EditForm
    Inherits System.Web.UI.Page
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If (Not Page.IsPostBack) Then
            PopulateEditForm()
        End If
    End Sub
    Protected Sub PopulateEditForm()
        Dim row As DataRow = GetEditedRow()
        TextBox1.Text = row("FirstName").ToString()
        TextBox2.Text = row("LastName").ToString()
        TextBox3.Text = row("Title").ToString()

    End Sub

    Protected Function GetEditedRow()
        Dim myDataTable As DataTable = Session("gridSource")
        Dim row As DataRow = myDataTable.Select("EmployeeID = " & Request.QueryString("EmployeeId"))(0)
        Return row

    End Function

    Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
        Dim updatedRow As DataRow = GetEditedRow()

        updatedRow("FirstName") = TextBox1.Text
        updatedRow("LastName") = TextBox2.Text
        updatedRow("Title") = TextBox3.Text

        InjectScript.Text = "<script type='text/javascript'>CloseAndRebind()</" + "script>"

    End Sub
End Class
