473,386 Members | 2,129 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.

DataGrid Itemcreated Problem!

How come that if you have a simple page with a data grid and a button.

When you load the first time (coming to the page first time) events happens
in this order:

1. Page_Load() (including a call to bind the grid)
2. Grid_itemCreated()

But if you press the Button (that ttriggers a postback) they happen in this
order?
1. Grid_ItemCreated()
2. Page_Load
3. Grid_ItemCreated()
4. Button_Click()

WHY WHY WHY... does the Item_Created happen before Page Load on a
postback... What triggers that????

Best Regards/
Lars Netzel

Nov 19 '05 #1
1 1000
Hello Lars,

Just a guess here...

Controls are repopulated from ViewState somewhere between OnInit and OnLoad.
So, your grid is getting recreated twice.

You could try wrapping the call in OnLoad with if (!Page.IsPostBack).

--
Matt Berther
http://www.mattberther.com
How come that if you have a simple page with a data grid and a button.

When you load the first time (coming to the page first time) events
happens in this order:

1. Page_Load() (including a call to bind the grid) 2.
Grid_itemCreated()

But if you press the Button (that ttriggers a postback) they happen in
this
order?
1. Grid_ItemCreated()
2. Page_Load
3. Grid_ItemCreated()
4. Button_Click()
WHY WHY WHY... does the Item_Created happen before Page Load on a
postback... What triggers that????

Best Regards/
Lars Netzel

Nov 19 '05 #2

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

Similar topics

3
by: vinayak | last post by:
Hi I am displaying data in Datagrid in ASP.NET with Edit/Update functionality for each row. On the same page I have 2 Button controls which submits the request to server. These button controls...
2
by: Jason | last post by:
I have a datagrid inside a user control. I use the itemcreated event to manipulate column values. I then add those values up and place the total in the footer of the datagrid. I have wrapped the...
0
by: Steve R | last post by:
I have a Datagrid with several TemplateColumns. I am creating ALL (BoundColumn & TemplateColumn) of the columns for the DataGrid during the PAGE_INIT. One TemplateColumn is a checkbox that allows...
1
by: Steve R | last post by:
I have a Datagrid with several TemplateColumns. I am creating ALL (BoundColumn & TemplateColumn) of the columns for the DataGrid during the PAGE_INIT. One TemplateColumn is a checkbox that allows...
2
by: Ben | last post by:
Hi, I'd like to have a datagrid that has a dropdownlist in the pager control for setting the page size. I can get the control into the pager inside the datagrid itemcreated event by checking for...
1
by: Lars Netzel | last post by:
Hello! When you Click Edit of a DataGrid row I, in EditCommand sub, set the right Index and recnid the DataGrid. In ItemCreated (of that Bind) I fill a DropDownlist ( buy adressing it with...
9
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...
5
by: Richard Myers | last post by:
Hello I have a datagrid that has a TemplatedColumn containing a dropdown list (DDL). This DDL is filled for each datagrid row via the itemcreated created event. The first time i postback none...
3
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",...
1
by: thebison | last post by:
Hi all, I hope someone can help with this relatively simple problem. I am building a timesheet application using ASP.NET C# with Visual Studio 2003.As it is only a protoype application, my...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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...
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
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...
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,...

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.