OnItemCreated

G

Guest

I have a DataList and I want to add some Javascript to a button in the Datalist. I am guessing that I will use the "OnItemCreated" event to find my control and then load the java script to the button.

The problem is that I can not find the control when I search for it in the event. I am guessing that internally it is assigning a unique ID to each of the buttons that the Datalist is creating and this is why I can not find the control with a "FindControl" method.

So how do I find the control? Here is the code I created...

if (e.Item.ItemType == ListItemType.Item | e.Item.ItemType ==
ListItemType.AlternatingItem)
{
Control ctrl = e.Item.FindControl("cmdPPIPEditDelete");
if (ctrl != null)
{
((Button)ctrl).Attributes["onclick"] = "return RecordDeleteConfirmation();";
}
}
 

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,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top