ItemCreated Event of datagrid is firing twice.

A

archana

Hi all,

I am having one datagrid whose datasource i set as array.

On itemcreated event i am having one counter which i have used to find
out how many times item created event is fired.

What i observerd is itemcreated event is fired twice than total items
present in array.

why is it so?

can anyone tell me reason behind this.

thanks in advance.
 
D

Danger

Hi all,

I am having one datagrid whose datasource i set as array.

On itemcreated event i am having one counter which i have used to find
out how many times item created event is fired.

What i observerd is itemcreated event is fired twice than total items
present in array.

why is it so?

can anyone tell me reason behind this.

thanks in advance.

Are you calling DataBind? Are you using an ObjectDataSource?
 
G

Guest

This could happen if you have subscribed to the event twice, e.g. if you have
placed in the HTML markup OnItemCreated and then issued an AddHandler in the
codebehind to wire up the same event. Search your project for the
occurrences of the method name; if you find it wired twice then that is the
cause of it.

Otherwise, it can be due to the databinding happening twice, e.g. if you
databind upon page_load but not use "If Not Page.IsPostBack Then" condition.
Set a break point in the last line of the eventhandler to see from where it
is being called.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top