DataGrid OnItemBound - Determine Table Row

Using ASP.NET 1.1
 I have a data grid with ImageButtons in some of the columns that, when clicked, perform actions against the data in the table.

I want to use the OnItemBound event on the grid to hide some of the image buttons depending on the data row.  More specifically, I want to hide a button for the 1st and last row in the table.
How can I identify which row is being created when the OnItemBound event is fired?
tfewster500Asked:
Who is Participating?
 
KarinLoosCommented:
If you want to know the total number of rows, then u could just query : Datagrid.Items.Count.
0
 
KarinLoosCommented:
the itemdatabound has 2 incoming args
object sender,
       System.Web.UI.WebControls.DataGridItemEventArgs e

example e.Item.Cells[0].Text;  is the text in the first cell of the current row.
e.item.cells[0].controls  - returns contro lcollection in that cell etc.
(remember to check that your on a rowtype datarow and not on a header row or footer row)
0
 
tfewster500Author Commented:
I'm familiar with those arguement as well as referring to the Text and Controls collection.

Question is, how do I tell what the row number is?
0
 
KarinLoosCommented:
e - (DataGridItemEventArgs) is a reference to the current row being bound.
e.Item.ItemIndex  == gives the index of this row within the datagrid.
0
 
tfewster500Author Commented:
Yes you are correct.  e.item.itemindex gives the row that is being actioned on each time the OnItemBound is being fired.  However, it does not tell me the the total number of rows.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.