control not being found on ItemDataBound

S

Stimp

I don't know why this isn't working for me, since I've run pages with
similar code that never had problems...

I want to access a control in a datalist on itemdatabound...

DATALIST ASPX:

<asp:datalist id="DataList1" runat="server" BorderWidth="0"
Width="100%" cellPadding="0" cellSpacing="0" DataKeyField="idUser"
OnItemDataBound="DataList1_ItemDataBound">

<ItemTemplate>
<asp:ImageButton id="imgDeleteUser" runat="server"
CommandName="DeleteUser" ImageUrl='../images/icons_delete.gif' />
</ItemTemplate>

</asp:datalist>


CODE-BEHIND (VB):

(databind code not shown)

Public Sub DataList1_ItemDataBound(ByVal sender As System.Object, ByVal
e As DataListItemEventArgs)

Dim imgDeleteUser As ImageButton = e.Item.FindControl("imgDeleteUser")
....

End Sub


When I step through to this point I get a value of 'Nothing' for the
imgDeleteUser control.. i.e. it's not being picked up

What's going on?!?

Thanks,
Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top