473,386 Members | 1,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 1498
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.FindControl 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.RowState | DataControlRowState.Edit ==
DataControlRowState.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">The Client GridView object.</param>
/// <param name="e">The GridViewRowEventArgs used to the the row
being updated.</param>
protected void gvClients_RowCreated(object sender,
GridViewRowEventArgs e)
{
GridViewRow row = e.Row;
if (row.RowType == DataControlRowType.DataRow)
{
if (row.RowState == DataControlRowState.Alternate ||
row.RowState == DataControlRowState.Normal)
{
BulletedList lstIdentification =
(BulletedList)row.FindControl("lstIdentifications" );
BulletedList lstRecipient =
(BulletedList)row.FindControl("lstRecipients");
lstIdentification.Items.Clear();
lstRecipient.Items.Clear();
if
((LDVComputers.BusinessEntities.Client)e.Row.DataI tem != null)
{
int SaveClientId = ClientId;
ClientId =
((LDVComputers.BusinessEntities.Client)e.Row.DataI tem).ClientId;
foreach
(LDVComputers.BusinessEntities.Identification identification in
_presenter.Identifications())
lstIdentification.Items.Add(new
ListItem(identification.IdentificationName + ": " +
identification.IdentificationNumber,
identification.IdentificationId.ToString()));
foreach (LDVComputers.BusinessEntities.Recipient
recipient in _presenter.Recipients())
lstRecipient.Items.Add(new
ListItem(recipient.RecipientFirstName + " " +
recipient.RecipientLastName, recipient.RecipientId.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
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
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...
0
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...
2
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...
1
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...
1
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...
3
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...
0
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...
5
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
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...

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.