Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls

Imports APNSoft.WebControls

Partial Public Class DataGrid_Templates_EditForm
    Inherits System.Web.UI.UserControl
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

        'Define the method (Insert or Update)
        Dim EditFormMethod As APNSoftDataGrid.EditFormMethodValues = APNSoftDataGrid.EditFormMethod


        'Insert method
        If EditFormMethod = APNSoftDataGrid.EditFormMethodValues.Insert Then
            Me.lblText.Text = "Enter the information below:"
            Me.txtCustomerID.Enabled = True
            Me.lblSubmit.Text = "<a href='javascript:InsertTheRow();'>Insert</a>"
        End If


        'Update method
        If EditFormMethod = APNSoftDataGrid.EditFormMethodValues.Update Then
            Me.lblText.Text = "Edit the information below:"
            Me.txtCustomerID.Enabled = False

            'Restore fields
            Me.txtCustomerID.Text = Server.HtmlDecode(APNSoftDataGrid.EditFormRow.Cells("CustomerID").Value.ToString())
            Me.txtCompanyName.Text = Server.HtmlDecode(APNSoftDataGrid.EditFormRow.Cells("CompanyName").Value.ToString())
            Me.txtContactName.Text = Server.HtmlDecode(APNSoftDataGrid.EditFormRow.Cells("ContactName").Value.ToString())
            Me.txtAddress.Text = Server.HtmlDecode(APNSoftDataGrid.EditFormRow.Cells("Address").Value.ToString())

            Me.lblSubmit.Text = "<a href='javascript:UpdateTheRow();'>Update</a>"
        End If

    End Sub
End Class