473,661 Members | 2,494 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

OnItemCreated Method Of DataGrid

In the .NET2.0 SDK Documentation, the DataGrid's OnItemCreated method
is described as thus:

The ItemCreated event is raised when an item in the DataGrid control
is created, both during round-trips and at the time data is bound to
the control.

Can someone please explain what does the above line mean preferably
with examples?

Apr 13 '07 #1
1 1509
On Apr 13, 5:56 pm, r...@rediffmail .com wrote:
In the .NET2.0 SDK Documentation, the DataGrid's OnItemCreated method
is described as thus:

The ItemCreated event is raised when an item in the DataGrid control
is created, both during round-trips and at the time data is bound to
the control.

Can someone please explain what does the above line mean preferably
with examples?
This is usually used when you are templating controls and need to set
them up. In this case you would use the e.row.FindContr ol method to
locate the template control using it's ID. You will need to convert
the Control returned by FindControl into the actual control type. Some
of the properties of the row that are useful for this is the RowType
and the RowState. The RowType of the row tells you if it is a header,
data or footer row. The RowState of the row tells you if the row is an
Edit, normal or alternate row. A warning, when looking for the Edit
row, you need to mask out the Edit type because it also has either the
normal or alternate enum value as well

If(e.row.RowSta te | DataControlRowS tate.Edit ==
DataControlRowS tate.Edit)
{
...
}

a complete example ...

/// <summary>
/// Update the Recipient list and the Identification list in the
Client GridView's Normal or Alternate rows.
/// </summary>
/// <param name="sender">T he Client GridView object.</param>
/// <param name="e">The GridViewRowEven tArgs used to the the row
being updated.</param>
protected void gvClients_RowCr eated(object sender,
GridViewRowEven tArgs e)
{
GridViewRow row = e.Row;
if (row.RowType == DataControlRowT ype.DataRow)
{
if (row.RowState == DataControlRowS tate.Alternate ||
row.RowState == DataControlRowS tate.Normal)
{
BulletedList lstIdentificati on =
(BulletedList)r ow.FindControl( "lstIdentificat ions");
BulletedList lstRecipient =
(BulletedList)r ow.FindControl( "lstRecipients" );
lstIdentificati on.Items.Clear( );
lstRecipient.It ems.Clear();
if
((LDVComputers. BusinessEntitie s.Client)e.Row. DataItem != null)
{
int SaveClientId = ClientId;
ClientId =
((LDVComputers. BusinessEntitie s.Client)e.Row. DataItem).Clien tId;
foreach
(LDVComputers.B usinessEntities .Identification identification in
_presenter.Iden tifications())
lstIdentificati on.Items.Add(ne w
ListItem(identi fication.Identi ficationName + ": " +
identification. IdentificationN umber,
identification. IdentificationI d.ToString()));
foreach (LDVComputers.B usinessEntities .Recipient
recipient in _presenter.Reci pients())
lstRecipient.It ems.Add(new
ListItem(recipi ent.RecipientFi rstName + " " +
recipient.Recip ientLastName, recipient.Recip ientId.ToString ()));
ClientId = SaveClientId;
}
}
}
}

Apr 14 '07 #2

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

Similar topics

1
23566
by: Dion Heskett | last post by:
How can I pass a Class as a parameter to in a method ? i.e. Private myMethod( string pram1, Classobject as pram2) { Classobject.DataSource = reader; Classobject.DataBind(); }
0
1331
by: Sam | last post by:
Hi, I have a class that receives a DataGrid control and populates it. However, I need to do an OnItemCreated event because if I'm missing data in a certain column, I display a HyperLink control in the DataGrid so that the user can enter the missing data. If there is data, I hide the HyperLink control. The problem is I pass the DataGrid control to a class and let the class populate it and return it to the ASPX page. I just don't know...
0
1099
by: Jim Heavey | last post by:
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...
2
1246
by: Jim Heavey | last post by:
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...
1
2515
by: Mauritsius | last post by:
I have a simple page where I would like to modify a repeater (bounded to a dataset) if a button (outside the repeater) is clicked or not. I tried to solve this with a button click event that raises a global flag and a repeater OnItemCreated event that modifies the repeater items accordingly. My problem is that the click event for the button is fired after the OnItemCreated event for the repeater when the flag still has a default...
1
1550
by: Arpan | last post by:
Consider the following code which populates a DataGrid with the items of a string array: Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs) If (ViewState("Colors") Is Nothing) Then arrColors = New String(3) {"red", "blue", "pink", "white"} ViewState("Colors") = arrColors Else arrColors = ViewState("Colors") End If
3
1403
by: Arpan | last post by:
A DataGrid displays data from a DataSet. The DataGrid has the OnItemCreated event. Assume that the OnItemCreated event calls a sub named "InEditMode()". The DataGrid gets rendered as soon as this ASPX page loads in the browser. Now since the DataGrid has got its OnItemCreated event, will it's event function i.e. "InEditMode()" execute before the Page_Load sub executes or will it execute after the Page_Load sub gets executed? Thanks,
0
1747
by: Erik | last post by:
Why isn't my update method getting called? Pasted below is an aspx from a 1.1 application I'm working on. It has two textboxes and a button for inserting data into the database, and a datagrid for editing and deleting data. When a user clicks on the "Edit" button in the datagrid, Edit() method is called and the appropriate row is changed into textboxes. And if user clicks on the "Update" button, the Update() method is fired. But if...
5
3104
by: rn5a | last post by:
The .NET 2.0 documentation states the following: When using a DataSet or DataTable in conjunction with a DataAdapter & a relational data source, use the Delete method of the DataRow to remove the row. The Delete method marks the row as Deleted in the DataSet or DataTable but does not remove it. Instead when the DataAdapter encounters a row marked as Deleted, it executes its DeleteCommand method to delete the row at the data source. The...
0
8432
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
8343
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8758
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8545
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
8633
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4346
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
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
1986
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1743
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.