Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > OnItemCreated

Reply
Thread Tools

OnItemCreated

 
 
=?Utf-8?B?SmltIEhlYXZleQ==?=
Guest
Posts: n/a
 
      06-23-2004
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();";
}
}


 
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
Event handling: Button Click Vs Repeater OnItemCreated Mauritsius ASP .Net 1 12-17-2004 03:20 PM
OnItemCreated Event =?Utf-8?B?SmltIEhlYXZleQ==?= ASP .Net 2 06-23-2004 01:09 PM
OnItemCreated Event =?Utf-8?B?SmltIEhlYXZleQ==?= ASP .Net 0 06-23-2004 11:26 AM
OnItemCreated Event =?Utf-8?B?SmltIEhlYXZleQ==?= ASP .Net 0 06-23-2004 11:25 AM
OnItemCreated =?Utf-8?B?SmltIEhlYXZleQ==?= ASP .Net 0 06-23-2004 11:25 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57