DetailsView Problem

I have 2 button which run the same sub.


One in a details view and one outside the details view.

The button outside the details view runs the code fine and displays the indented message in the label and pops the modal.

The button inside the details view pops the modal but does not populate the label

What's the difference?

 Private Sub SubChechAppDate()
            If Session("Rebook") = "Rebook" Then


                Dim conn3 As SqlConnection
                Dim com3 As SqlCommand
                Dim objDR3 As SqlDataReader
                Dim connectionString3 As String = ConfigurationManager.ConnectionStrings("IRISConnectionString").ConnectionString
                conn3 = New SqlConnection(connectionString3)
                com3 = New SqlCommand()

                com3.Connection = conn3

                com3.CommandType = CommandType.StoredProcedure

                com3.CommandText = "ValidateRebooking"
                com3.Parameters.Add("@EventID", SqlDbType.Int).Value = GVCurrentAppointments.SelectedDataKey.Values("EVENTID").ToString().Trim()
                com3.Parameters.Add("@NEWDATE", SqlDbType.DateTime).Value = Convert.ToDateTime(DirectCast(dvInsertApt.FindControl("txtAptStartDate"), TextBox).Text).[Date]
                conn3.Open()
                objDR3 = com3.ExecuteReader()

                While objDR3.Read()

                    lblMessage.Text = objDR3("VALID")

                    lbNextApt.Text = objDR3("nextapt")

                    'lbNextApt.Text = objDR3("NEXTAPT")



                    'lblMessage.Text = GVCurrentAppointments.SelectedDataKey.Values("EVENTID").ToString().Trim()

                    'lbNextApt.Text = dvInsertApt.FindControl("txtAptStartDate")


                    If objDR3("VALID") = 0 Then



                        lbNoBook.Text = "You cannot make a rebooking on " + Convert.ToDateTime(DirectCast(dvInsertApt.FindControl("txtAptStartDate"), TextBox).Text).[Date] + "." + " " + "Please try a new date but it must be before" + " " + objDR3("nextapt")

                    Else

                        lbNoBook.Text = "you should not see this...."
                    End If

                End While

                objDR3.Close()
                conn3.Close()

                Session("appStartDate") = Convert.ToDateTime(DirectCast(dvInsertApt.FindControl("txtAptStartDate"), TextBox).Text).[Date]

                mp1.Show()

            End If

Open in new window



Part of the code that won't work with button inside detailsview.


                    If objDR3("VALID") = 0 Then



                        lbNoBook.Text = "You cannot make a rebooking on " + Convert.ToDateTime(DirectCast(dvInsertApt.FindControl("txtAptStartDate"), TextBox).Text).[Date] + "." + " " + "Please try a new date but it must be before" + " " + objDR3("nextapt")

                    Else

                        lbNoBook.Text = "you should not see this...."
                    End If

Open in new window

EdAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

EdAuthor Commented:
solved myself
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
EdAuthor Commented:
im great
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.