我想要做的是從page_load中獲取intGuestID1以便在bth_add區域中使用 因爲我試圖從已點擊的位置獲取ID另一種形式frmAddFollowUp,所以我試圖從page_load請求它,因爲當我從添加按鈕請求時,它只會給我數字0而不是以前的形式的ID。我如何獲得從一個子對象到另一個子
Partial Class frmAddFollowUp
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim objCDBFeedback As New CDBFeedback
Dim objCDBDepartment As New CDBDepartment
Dim intGuestID1 As Integer
Dim arrList As New ArrayList
If Page.IsPostBack = False Then
intGuestID1 = Request.QueryString("id")
arrList = objCDBDepartment.getAllDepartmentDropDownList
lstDepartment.DataSource = arrList
lstDepartment.DataTextField = "DepartmentName"
lstDepartment.DataValueField = "Department"
lstDepartment.DataBind()
End If
End Sub
Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim CheckBoolean As Boolean = True
Dim objCDBFeedback As New CDBFeedback
Dim objCFeedback As New CFeedback
If txtStaffName.Text = "" Then
lblValidateStaffName.Text = "*Please enter Staff Name."
CheckBoolean = False
Else
lblValidateStaffName.Text = ""
End If
If txtFollowUpSummary.Text = "" Then
lblValidateFollowUpSummary.Text = "*Please enter Follow up summary."
CheckBoolean = False
ElseIf txtFollowUpSummary.Text.Contains("'") Then
txtFollowUpSummary.Text = txtFollowUpSummary.Text.Replace("'", "''")
Else
lblValidateFollowUpSummary.Text = ""
End If
If txtAmount2.Text = "" Then
lblValidateAmount2.Text = "*Please enter the Amount or put in NIL if there is no amount."
CheckBoolean = False
Else
lblValidateAmount2.Text = ""
End If
If CheckBoolean = False Then
If txtStaffName.Text.Contains("''") Then
txtStaffName.Text = txtStaffName.Text.Replace("''", "'")
End If
If txtFollowUpSummary.Text.Contains("''") Then
txtFollowUpSummary.Text = txtFollowUpSummary.Text.Replace("''", "'")
End If
Else
Dim intNumOfRecordsAffected As Integer
objCFeedback.GuestId = intGuestID1
objCFeedback.Feedback = txtFollowUpSummary.Text
objCFeedback.Department = lstDepartment.SelectedItem.Value
objCFeedback.StaffName = txtStaffName.Text
objCFeedback.Amount = txtAmount2.Text
intNumOfRecordsAffected = objCDBFeedback.addNewFollowUp(objCFeedback)
Response.Redirect("frmIncident.aspx")
End If
End Sub
我如何讓它成爲私人成員變量?對不起,在這個新的..至於intGuestID1不在btnAdd_click中聲明..因爲我在想我是否可以在page_load中聲明它,並將其帶入到btnAdd_click,但我不知道代碼採取 – waterbottle 2012-01-13 03:38:29
沒有需要對不起,我們都從某個地方開始。給我一下,我會更新我的答案,如何做到這一點 – 2012-01-13 03:41:08