|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Datagrids and User ControlsI have a datagrid in a user control with specific properties of the
datagrid exposed which I have used in many different aspx pages. I also have the itemdatabound event handled in the user control. I now need to change the OnItemDataBound event of the grid for a couple of pages. Is there any way of doing so ( akin to "overriding" the event in the page the user control resides ). I hope this makes sense. --------- Nicolaj Hi,
basically you could define Grid_ItemDataBound (name it as you like) event in the user control, declare it similarly as ItemDataBound is declared. Just raise that event when ItemDataBound in the grid raises (pass event arguments also), so Page could handle if it needs to the event Here's a small sample: 'In the UC Partial Class WebUserControl2 Inherits System.Web.UI.UserControl Public Event Grid_ItemDataBound As DataGridItemEventHandler Protected Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound 'Passing reference to DataGrid also RaiseEvent Grid_ItemDataBound(Me.DataGrid1, e) End Sub End Class 'On the page:L ID of the UC is WebUC2 Protected Sub MyUC2_Grid_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles MyUC2.Grid_ItemDataBound End Sub Show quoteHide quote "Nicolaj" <shri***@gmail.com> wrote in message news:1152346034.327337.58590@75g2000cwc.googlegroups.com... >I have a datagrid in a user control with specific properties of the > datagrid exposed which I have used in many different aspx pages. I also > have the itemdatabound event handled in the user control. > > I now need to change the OnItemDataBound event of the grid for a > couple of pages. Is there any way of doing so ( akin to "overriding" > the event in the page the user control resides ). I hope this makes > sense. > > --------- > Nicolaj >
Dropdown List doesn't know what's in it's list
dropdown list post back not working Max Number of Web Controls Per Page??? ObjectDataSource ControlParameters problem with hidden field from a custom control in a form Problem with ASP.NET wizard hiding / removing steps Custom Templated CompositeControl/CompositeControlDesigner Datagrid Control in VS2005 GridView columns don't respect width or wrap properties! WebControl and JavaScript |
|||||||||||||||||||||||