View Single Post
  #4 (permalink)  
Old May 3rd, 2011, 05:15 AM
Phil Critchley Phil Critchley is offline
Authorized User
 
Join Date: Feb 2011
Posts: 37
Thanks: 8
Thanked 0 Times in 0 Posts
Default Gridview RowCommand Event

Hi Imar

Thank you for the quick reply.

I have a gridview in my project which I have added ButtonField controls too. I have got the control to fire an associated procedure but I want it to confirm the procedure with a popup message to the user. I.e. "this publication reservation has now been cancelled".

I've found alot of references for calling Javascript functions from code behind but absolutely none for calling them from code behind within Gridview RowCommand especially when working with buttonfield controls?

Code:
If (e.CommandName = "Cancel") Then

            ' Retrieve the row index stored in the CommandArgument property.
            Dim index As Integer = Convert.ToInt32(e.CommandArgument)

            ' Retrieve the row that contains the button from the Rows collection.
            Dim row As GridViewRow = GridViewReservations.Rows(index)
            PublicationID = row.Cells(0).Text

            ' Retrieve the row that contains the button from the Rows collection.
            Dim rowTwo As GridViewRow = GridViewReservations.Rows(index)
            Status = rowTwo.Cells(2).Text

            If Status = "Out on Loan\Reserved for Loan" Then

                Using myLiteratureCatalogue As New Model1.Literature_Cataloguing_SystemEntities
                    Dim reservationStatus = (From publication In myLiteratureCatalogue.Publications Where publication.PublicationID = (PublicationID) Select publication).First()

                    ' Change the status of the publication.
                    reservationStatus.ReservationID = Nothing
                    reservationStatus.StatusID = (2)

                    myLiteratureCatalogue.SaveChanges()

                End Using

                POPUP CONFIRMATION GOES HERE
                System.Threading.Thread.Sleep(5000)
                Response.Redirect(Request.RawUrl)

            ElseIf Status = "Reserved for Loan" Then

                Using myLiteratureCatalogue As New Model1.Literature_Cataloguing_SystemEntities
                    Dim reservationStatus = (From publication In myLiteratureCatalogue.Publications Where publication.PublicationID = (PublicationID) Select publication).First()

                    ' Change the status of the publication.
                    reservationStatus.ReservationID = Nothing
                    reservationStatus.StatusID = (1)

                    myLiteratureCatalogue.SaveChanges()

                End Using

                POPUP CONFIRMATION GOES HERE
                System.Threading.Thread.Sleep(5000)
                Response.Redirect(Request.RawUrl)

            End If

        End If
Thanks
Reply With Quote