473,396 Members | 1,706 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,396 software developers and data experts.

OnItemCreated DataGrid?

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,

Arpan

Aug 10 '06 #1
3 1393
Hi,
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.

The ItemCreated event is commonly used to control the content and
appearance of a row in the DataGrid control.

Sub Item_Created(sender As Object, e As DataGridItemEventArgs)

Label1.Text = Label1.Text & " " & e.Item.ItemIndex
End Sub 'Item_Created

<asp:DataGrid id="ItemsGrid" runat="server"
BorderColor="black"
BorderWidth="1"
CellPadding="3"
ShowFooter="true"
OnItemCreated="Item_Created"
AutoGenerateColumns="true">

Regards
bhar
knowledge is power
http://www.vkinfotek.com

*** Sent via Developersdex http://www.developersdex.com ***
Aug 11 '06 #2
Hi,
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.

The ItemCreated event is commonly used to control the content and
appearance of a row in the DataGrid control.

Sub Item_Created(sender As Object, e As DataGridItemEventArgs)

Label1.Text = Label1.Text & " " & e.Item.ItemIndex
End Sub 'Item_Created

<asp:DataGrid id="ItemsGrid" runat="server"
BorderColor="black"
BorderWidth="1"
CellPadding="3"
ShowFooter="true"
OnItemCreated="Item_Created"
AutoGenerateColumns="true">

Regards
bhar
knowledge is power
http://www.vkinfotek.com

*** Sent via Developersdex http://www.developersdex.com ***
Aug 11 '06 #3
Timmy, I am very well aware of whatever you have said & thanks for the
same. Actually my primary intention of posting that question was to get
my confusions clarified on the difference between the firing of the
Page_Load sub & the DataGrid's OnItemCreated event.

Consider the following code snippet:

<script runat="server">
Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
'connecting to a database table, retrieving
'records & display them in the DataGrid
DataGrid1.DataBind()
End Sub

Sub CreateItem(ByVal obj As Object, ByVal ea As
DataGridItemEventArgs)
Dim intIndex As Integer = ea.Item.ItemIndex
'some code here
DataGrid1.DataBind()
End Sub
</script>
<form runat="server">
<asp:DataGrid ID="DataGrid1" OnItemCreated="CreateItem"
AutoGenerateColumns="false" runat="server">
<Columns>
<asp:TemplateColumn HeaderText="Name">
<ItemTemplate>
<asp:Label ID="lblName" runat="server"><%# Container.DataItem("Name")
%></asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="Adr" HeaderText="Address"/>
<asp:BoundColumn DataField="City" HeaderText="City"/>
<asp:BoundColumn DataField="State" HeaderText="State"/>
<asp:BoundColumn DataField="Ctry" HeaderText="Country"/>
<asp:EditCommandColumn HeaderText="CHANGE" EditText="EDIT"
UpdateText="CHANGE" CancelText="CANCEL" runat="server"/>
</Columns>
</asp:DataGrid>
</form>

When the user comes to this page for the first time, "Page_Load" will
execute first after which the "OnItemCreated" event will be fired. Next
the user clicks the "EDIT" link. If I am not mistaken, this means that
ASP.NET will have to create this page again right from the scratch when
the "EDIT" link is clicked (please do correct me if I am wrong). Under
such circumstances, will "Page_Load" execute before the "OnItemCreated"
event fires or will the "OnItemCreated" event fire before "Page_Load"
executes?

Thanks,

Arpan

timmy123 narra wrote:
Hi,
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.

The ItemCreated event is commonly used to control the content and
appearance of a row in the DataGrid control.

Sub Item_Created(sender As Object, e As DataGridItemEventArgs)

Label1.Text = Label1.Text & " " & e.Item.ItemIndex
End Sub 'Item_Created

<asp:DataGrid id="ItemsGrid" runat="server"
BorderColor="black"
BorderWidth="1"
CellPadding="3"
ShowFooter="true"
OnItemCreated="Item_Created"
AutoGenerateColumns="true">

Regards
bhar
knowledge is power
http://www.vkinfotek.com

*** Sent via Developersdex http://www.developersdex.com ***
Aug 11 '06 #4

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

Similar topics

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...
1
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls...
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...
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...
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...
2
by: CSL | last post by:
I am using the DataGrid in a Windows Application, how can I adjust the widths of each column individually.
7
by: Dave | last post by:
Are there any add-on products or samples available that can do the following in an vb.net datagrid I want to compare 2 rows in a datagrid - one row from one database and another row for another...
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...
1
by: rn5a | last post by:
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
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,...

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.