• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 63
  • Last Modified:

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

0
Ed
Asked:
Ed
  • 2
1 Solution
 
EdAuthor Commented:
solved myself
0
 
EdAuthor Commented:
im great
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now