when you build the control you will need to set it's id to a unique value.
then you will need to daisy chain the click event to a handler
button1.click+=new handler(myhandler)
in the event handler, you would use e.id or cast the sender argument to
extract the id

"Jim Mitchell" <jim_mitchell@mindspring.com> wrote in message
news:ObP10MdUDHA.584@TK2MSFTNGP12.phx.gbl...
> I have added two controls in the pre-render module. How can I define an
> onclick event for these controls if I do not know the names of the
controls
> at run time...
>
> Thanks in advance.
>
> Private Sub dgAccounts_PreRender(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles dgAccounts.PreRender
>
> Dim img As ImageButton
>
> Dim img2 As ImageButton
>
> img = New ImageButton
>
> img2 = New ImageButton
>
> img.ImageUrl = "images/folder.gif"
>
> img2.ImageUrl = "images/find.gif"
>
> dgAccounts.Items(6).Controls(1).Controls.Add(img)
>
> dgAccounts.Items(6).Controls(3).Controls.AddAt(0, img2)
>
> End Sub
>
>