Where is my DataGrid's Header, Footer and Pager items in?

R

RB

Hi,

I have a web page with a DataGrid that uses default pagination. Even though
the PagerStyle is Numbers, I have added two link buttons (Next and Prev) in
the Pager item.

So now, on the DataGrid's Header and Footer the Pager shows: Next 1 2 3 4 Prev

The problem is that I would like to access the "Next" and "Prev" buttons,
but my datagrid's item collection seems to have only the data rows thus I
can't access the Header, footer or any of the pagers. For Example:

MyDataGrid.Items(0).ItemType is either "Item" or "AlternatingItem"

So other DataGridItem types like Header, Footer and Pager are lost.
In what collection of my datagrid are this items found?

Any ideas?

Thank you in advance.

RB
 
S

Scott Mitchell [MVP]

RB said:
The problem is that I would like to access the "Next" and "Prev" buttons,
but my datagrid's item collection seems to have only the data rows thus I
can't access the Header, footer or any of the pagers. For Example:

MyDataGrid.Items(0).ItemType is either "Item" or "AlternatingItem"

From the documentation (http://tinyurl.com/5ymf7):

"Only items bound to the data source are contained in the Items
collection. The header, footer, and separator are not included in the
collection."

If you need to access/modify the contents of the header/footer/pager,
you need to do so during the ItemCreated or ItemDataBound events. These
are events that fire once for each row added to the DataGrid, which
happens only when its DataBind() method is called.

The technical docs for these two events is online at:

http://tinyurl.com/3qldj
-and-
http://tinyurl.com/4mr9k

Happy Programming!

--

Scott Mitchell
(e-mail address removed)
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!
 
R

RB

That's correct, indeed I created the "Prev" and "Next" buttons through the
ItemCreated event. The problem is that I intend to reference these controls
after they were created, at page's Load and/or PreRender time.

So, I guess that I would have to save a reference to the naming container or
to the buttons themself that I can access from my page's load or prerender
handlers :(
It does not sound like to elegant, but it could work.

Thanks for the info. If anything additional comes up, please let me know.

RB
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,076
Latest member
OrderKetoBeez

Latest Threads

Top