ItemDataBound event woes...

R

Roy

Hey all,
This is a fairly broad question, but why is it that my datagrid hits
the ItemDataBound event 3 times?

Basically, I placed a response.write in all sub and functions in my
codebehind and discovered that my page_load,prerender,and binddata subs
all get called once, but my itemdatabound event gets called 3 times.
What's weird is that there is only 1 row being pushed into the
datagrid, so I should only be seeing one itemdatabound call, right?
Certainly not 3...

On a hunch, I'm thinking that somehow the 3 calls represent the
datagrid header, content, and footer... Am I misunderstanding this?
 
G

Guest

Hi Roy,

In ItemDataBound event all items (including ListItemType.Item,
ListItemType.Header, and ListItemType.Footer) are processed. In order to
avoid process header and Footer, you can code like

if (e.Item.ItemType == ListItemType.Item || ListItemType.Item ==
ListItemType.AlternatingItem)
{
// process
}

HTH

Elton Wang
(e-mail address removed)
 

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

Top