Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Datagrids and User Controls

Reply
Thread Tools

Datagrids and User Controls

 
 
Nicolaj
Guest
Posts: n/a
 
      07-08-2006
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

 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      07-10-2006
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

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke




"Nicolaj" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ps.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
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using user controls in datagrids =?Utf-8?B?TW9vampvbw==?= ASP .Net 2 07-08-2005 06:50 PM
using javascript in User controls to access server controls of the user control Faizan Ahmed ASP .Net Building Controls 1 01-04-2005 04:09 PM
User Controls with in datagrids Zi ASP .Net 0 10-02-2003 02:22 PM
User Controls with in datagrids Zi ASP .Net Building Controls 0 10-02-2003 02:22 PM
Wanted: Samples Fancy Controls and Datagrids Siegfried Heintze ASP .Net Web Controls 0 09-23-2003 07:14 PM



Advertisments