Raising Events

In Default.aspx I have a user control (<WI:editBOM runat="server" id="ctlEdit" />)  I want to refresh  the ctlEdit dropdownlist when another control fires (BOM.ascx)
 
So in DEFAULT.aspx I add this sub

Private Sub ctlNew_drpBOM_Change() Handles ctlNew.drpBOM_Change
ctlEdit.drpbomChange()
End Sub

In the EDITBOM.ASCX file I add this subroutine essentially rebinding the dropdownlist

Public Sub drpbomChange()

drpBOM.DataSource = VendorBid_Data.itemAttributesvb.getValidBOMStyles()
drpBOM.DataBind()
drpBOM.Items.Insert(0,

"Choose Style")

End Sub

In the BOM.ASCX file I declare the event and raise the event:

Public Event drpBOM_Change()

I raise the event at the point I want to fire it....

RaiseEvent drpBOM_Change()


Thus we have a page that holds two controls - when one dropdownlist or event fires then the other control dropdownlist is refreshed.  This enables me to load up my controls on the page but if circumstances change and the dropdownlist on one needs to be refreshed then I have control over that single page event.


Comments

Popular posts from this blog

Linq Exclude from separate list

Sorting Ascending and Descending

Linq Query Syntax vs Method Syntax