473,699 Members | 2,506 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataLists ItemCreated question

I am trying understand when DataLists ItemCreated is called.

I put function that attaches a popup to my delete button:

Sub DataList_ItemCr eated(Sender As Object, e As DataListItemEve ntArgs)
trace.warn("Ins ide DataList_ItemCr eated Sender = " &
sender.GetType( ).tostring())
trace.warn("Ite mtype = " & e.Item.ItemType & " " &
e.Item.ItemType .ToString())
Select Case e.Item.ItemType
Case ListItemType.It em, ListItemType.Al ternatingItem,
ListItemType.Ed itItem
trace.warn(" Setting up myDeleteButton" )
Dim myDeleteButton As LinkButton
myDeleteButton = e.Item.FindCont rol("btnDel")
if not myDeleteButton is nothing
myDeleteButton. Attributes.Add( "onclick", "return confirm('Are you sure
you want to delete this question?');")
end if
End Select
trace.warn("lea ving DataList_ItemCr eated")
End Sub

But it seems to be called all over the place. In my trace I have the
following (I won't put all of them there), including the traces from the
above routine.

*************** *************** *************** *************** *************** **
aspx.page Begin Init
aspx.page End Init
aspx.page Begin LoadViewState
Inside DataList_ItemCr eated Sender = System.Web.UI.W ebControls.Data List
Itemtype = 2 Item
Setting up myDeleteButton
leaving DataList_ItemCr eated
Inside DataList_ItemCr eated Sender = System.Web.UI.W ebControls.Data List
Itemtype = 6 Separator
leaving DataList_ItemCr eated
Inside DataList_ItemCr eated Sender = System.Web.UI.W ebControls.Data List
Itemtype = 3 AlternatingItem
Setting up myDeleteButton
leaving DataList_ItemCr eated
....
aspx.page End LoadViewState
aspx.page Begin ProcessPostData
aspx.page End ProcessPostData
inside Page_load
aspx.page Begin ProcessPostData Second Try
aspx.page End ProcessPostData Second Try
aspx.page Begin Raise ChangedEvents
aspx.page End Raise ChangedEvents
aspx.page Begin Raise PostBackEvent
inside OnSelectIndex e.CommandName = Edit
inside DataListEdit
Inside DataList_ItemCr eated Sender = System.Web.UI.W ebControls.Data List
Itemtype = 2 Item
Setting up myDeleteButton
leaving DataList_ItemCr eated
Inside DataList_ItemCr eated Sender = System.Web.UI.W ebControls.Data List
Itemtype = 6 Separator
leaving DataList_ItemCr eated
Inside DataList_ItemCr eated Sender = System.Web.UI.W ebControls.Data List
Itemtype = 3 AlternatingItem
Setting up myDeleteButton
leaving DataList_ItemCr eated
....
*************** *************** *************** **************

The same ones that are called in LoadViewState are also called in Raise
PostBackEvent. How do I tell which one is the delete button?

I found the problem when I ran this and tried to push the button on the left
of the delete button. It gave me an error that the object wasn't there. If
I push the delete button it works fine. I assume this is because it isn't
created yet. I get the error in the Raise PostBackEvent and not in the
LoadViewState.

At the moment, the button is being set up in the ListItemType.It em,
ListItemType.Al ternatingItem and ListItemType.Ed itItem. Not sure why, but
that was how it was done in the example code I got this from.

I would like to only attach it once. I am not sure why this was done in
this event. I would think I could set it in the Page_load event (but maybe
not).

Thanks,

Tom
Nov 19 '05 #1
1 1508
On Mon, 14 Mar 2005 16:27:26 -0800, "tshad"
<ts**********@f tsolutions.com> wrote:
I am trying understand when DataLists ItemCreated is called.

I put function that attaches a popup to my delete button:


Tom:

Are you calling DataBind during the post back event? If so, I imagine
you are seeing ItemCreated fired once when the grid is restored from
ViewState, and once again when you data bind and recreate the grid.
Perhaps you'll want to attach to the ItemDataBound event, but I can't
tell for sure without digging into the code a little more.

--
Scott
http://www.OdeToCode.com/blogs/scott/
Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1111
by: Jonathan Hollinger | last post by:
Very, very strange problem. In developing a C# ASP.NET application, every so often, DataLists disappear from the build. They remain visible and rendered (though sometimes dropping properties and event handlers) but do not seem to be included in the build (and are consequently not rendered on the web page). I've looked into the problem throughly, comparing output library sizes and it seems as though DataLists (all datalists on a page)...
1
627
by: Kevin Hector | last post by:
Hi. Can anyone explain why, when setting the Text of a Label control in the ItemCreated event of a Repeater (example below), the Text value is NOT persisted to ViewState? I know this can be fixed by using the ItemDataBound event, but I don't understand why. here's a page snippet: <asp:Repeater runat="server" id="myRepeater" OnItemCreated="myRepeater_ItemCreated"> ... <ItemTemplate><tr><td><asp:Label id="myLabel" runat="server"...
1
1369
by: Lars Netzel | last post by:
Hi! I'm so confused right now.. I have a Page that load a datagrid with a a bunch of radiobuttons in three columns which are then checkes or uncheck in the ItemCreated.(it's supposed to be a permission setting for different things in my application) There is a save button on the page to save the permissions set in the grid. The BindGrid() is called if it is NOT a postback in the PageLoad. Then, in debugging, when the User presses the...
9
2329
by: Manuel | last post by:
I have a Datagrid with 9 elements. The problem is that when I sort the grid by a column, it present more columns than there are. This is my code for the ItemCreated event: Private pNo As Integer = 0 Private Sub grd_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles grd.ItemCreated
2
1351
by: Nathan Sokalski | last post by:
I have a page on which I want to display several sections each of which contain a list of names. I have two database tables, one of which contains the section headings, and the other contains the names and which section they belong to. I would like to use databinding to display this information, preferably using DataLists. However, because the number of sections will vary, the DataLists will need to be added dynamically. But because...
3
3318
by: Lars Netzel | last post by:
(applies to Windows Form .NET 2003) I'm filling a datagrid from a Datatable and applying a DataGridStyle. The Source Fields are "Name", "Value", "Locked" and the Style's Columns are "Name", "Value" Depending on the "Locked" field in the source... I want the "Value" cell to be readonly or not for each row
2
1071
by: Diffident | last post by:
Hello All, I have a question on datalists. I have 5 datalists on a page and when I try to view the "ViewSource", the value for the __VIEWSTATE is empty. How do datalists persist their values? I am not binding the datalist each and every time. Strangely whenever I try to access datalist elements from Datalist_ItemCommand it is maintaining it's viewstate. How is this possible?
3
1799
by: jason.gladstone | last post by:
Hello - I am trying to create a repeater control that contains a dropdownlist. A friend of mine sent me a sample in C#. I am trying to duplicate the sample in VB. This is the C# code in the OnLoad event: //bind the items to the repeater this.repeater.DataSource = items; this.repeater.ItemCreated += new RepeaterItemEventHandler(repeater_ItemDataBound); this.repeater.DataBind();
2
2388
by: Ole V.-M. | last post by:
Greetings, i have a UserControl, that contains a DataList. That DataList contains as items other DataLists. example: DataList A Row 1 Nested DataList 1 Row 1
0
8686
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9173
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8911
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7748
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6533
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4375
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3057
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2345
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2009
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.