无法从页面加载表单中的后面代码访问在转发器控件中找到的标签

时间:2019-06-18 14:03:12

标签: asp.net vb.net

我有一个中继器控件,该中继器控件包含一些标签。我需要在页面加载中使用这些标签,但是当我键入它时,它会带有下划线-意味着找不到。

下面是我的代码,我想在我的中继器控件中引用我的标签。我的中继器控件的ID = RepeaterEmployee

   Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load


        If Not Me.IsPostBack Then
            ' LoadGridAll()

            Dim EmployeeCode = Request.QueryString("ID")

            If EmployeeCode Is Nothing Then
                Response.Redirect("ReceptionistViewMedicalReports.aspx")
            End If

            Using conn As New SqlConnection(ConfigurationManager.ConnectionStrings("##").ConnectionString)

                Using cmd As New SqlCommand("SELECT EmployeeCodes.Code, EmployeeCodes.FirstName , EmployeeCodes.LastName , EmployeeCodes.EmployeeID , CostCentre , ExaminationType.ExaminationTypeName  , PhysicalExam.PhysicalExamName , ExaminationType.ExaminationTypeName, Audiogram.AudiogramName , AudiogramRec.AudiogramRecName, LungFunction.LungFunctionName,ChestResults,ECGResult,   DrugScreeningResult,BloodGlucoseResult,GGTResult,LeftEyeDayNight,RightEyeDayNight,LeftEyeCorrDayNight,RightEyeCorrDayNight,VisualFieldLeftDayNight,VisualFieldRightDayNight,ColourVisionDayNight,DeptPerceptionDayNight,OptometristYesNo,Outcome.Name ,OutcomeRecommendations.OutcomeRecommendationsName,OtherProblems,Notes,DateTested,NextDueDate,MedicalResults.Photo, Certificate FROM  MedicalResults, EmployeeCodes,  ExaminationType,PhysicalExam,Audiogram, AudiogramRec,LungFunction,Outcome,  OutcomeRecommendations, MedicalCertificate WHERE MedicalResults.EmployeeID = EmployeeCodes.EmployeeID AND ExaminationType.ExaminationTypeID = MedicalResults.ExaminationTypeID AND  PhysicalExam.PhysicalExamID = MedicalResults.PhysicalExamType AND Audiogram.AudiogramID = MedicalResults.AudiogramID AND MedicalResults.AudiogramRecID = AudiogramRec.AudiogramRecID AND LungFunction.LungFunctionID = MedicalResults.LungFunctionID AND OutcomeRecommendations.OutcomeRecommendationsID = MedicalResults.OutcomeRecommendationsID AND  Outcome.OutcomeID = MedicalResults.OutcomeID AND MedicalCertificate.MedicalCertificateID = MedicalResults.MedicalCertificateID WHERE (EmployeeCodes.Code = @Code)", conn)

                    cmd.Parameters.AddWithValue("@Code", EmployeeCode)

                    conn.Open()

                    Using rdr As SqlDataReader = cmd.ExecuteReader()

                        While rdr.Read()

            --I want to use labels here



                        End While


                    End Using

                    Dim sda As New SqlDataAdapter(cmd)
                    Dim dt As New DataTable()
                    sda.Fill(dt)
                    RepeaterEmployee.DataSource = dt
                    RepeaterEmployee.DataBind()          


                    conn.Close()

                End Using

            End Using

        End If

    End Sub

0 个答案:

没有答案