Viagra Canadian

Sep 4th, 2013 by Lynn Demarest in Miscellaneous

Generic drug for viagra When creating user controls, generic drug for viagra we sometimes need to notify the user of the control (usually a page or another user control) of something that happened in the control.

Generic drug for viagra Imagine a web page containing a gridview of Employer data and, generic drug for viagra beneath it, generic drug for viagra a user control containing a formview we use to edit a single Employer.

Generic drug for viagra When we select a row in the gridview, generic drug for viagra we use the SelectedIndexChanged event of the gridview to pass the ID of the selected Employer to the user control, generic drug for viagra which displays the Employer record in its formview.

Generic drug for viagra We discover, generic drug for viagra however, generic drug for viagra that when we update the formview the database is updated, generic drug for viagra but the gridview still displays the old data, generic drug for viagra which is misleading to the user.

Generic drug for viagra Wouldn’t it be cool if we could put an OnChange command in our user control that works just like the built-in controls do? So we could set up our user control like this:

<PP:EditEmployer runat="server" ID="EditEmployer1" OnEmployerUpdated="EditEmployer1_EmployerUpdated" />

Generic drug for viagra When we update the data in the EditEmployer user control, generic drug for viagra the control raises an EmployerUpdated event to notify the page containing the gridview that the data has changed. Generic drug for viagra The EditEmployer1_EmployerUpdated subroutine will be called to handle the event.

Generic drug for viagra Here’s how I do it.

Generic drug for viagra 1. Generic drug for viagra If you’re going to pass some data back with the event — in our case the ID of the record just saved — you’ll need to create a little class to hold it. Generic drug for viagra Place the event arguments class in the user control with the formview, generic drug for viagra after the close of the control class…

End Class ' This is the end of the code-behind in the user control class 
    Public Class EmployerUpdatedEventArgs
             Inherits EventArgs
    Public Property EmployerID As Integer
End Class

Generic drug for viagra 2. Generic drug for viagra Declare the event handler in the user control code. Generic drug for viagra I like to do this above the properties.

Public Event EmployerUpdated As EventHandler

Public Property EmployerID As String ... Generic drug for viagra 

Generic drug for viagra 3. Generic drug for viagra Raise the event when the form is updated. Generic drug for viagra (This is in our EditEmployer user control, generic drug for viagra the one with the formview.)

Protected Sub FormView1_ItemUpdated(sender As Object, generic drug for viagra e As FormViewUpdatedEventArgs) handles FormView1.ItemUpdated
        '
        ' raise an event to notify the caller that the item has been updated
        '

        ' first set up the event arguments   
        Dim arg As EmployerUpdatedEventArgs = New EmployerUpdatedEventArgs()
        arg.EmployerID = EmployerID

        ' fire the event, generic drug for viagra passing an instance of the EmployerUpdatedEventArgs class 
        RaiseEvent EmployerUpdated(Me, generic drug for viagra arg)
End Sub

Generic drug for viagra 4. Generic drug for viagra Catch the event in the page or control that uses the user control. Generic drug for viagra (This is the one with the gridview.)

    <!-- declare the event handler dynamically -->
    <PP:EditEmployer runat="server" ID="EditEmployer1" OnEmployerUpdated="EditEmployer1_EmployerUpdated" />

    Protected Sub EditEmployer1_EmployerUpdated(sender As Object, generic drug for viagra e As EmployerUpdatedEventArgs)
        Dim id As Integer

        id = e.EmployerID  ' we don't actually use this here. Generic drug for viagra But this is how it is passed. Generic drug for viagra 

        GridView1.DataBind()
    End Sub

Average Rating: 4.5 out of 5 based on 211 user reviews.

No Comments

 

Comments have been closed for this post.