Solved

DataGrid OnItemBound - Determine Table Row

Posted on 2007-03-21
7
286 Views
Last Modified: 2011-08-18
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?
0
Comment
Question by:tfewster500
  • 3
  • 2
7 Comments
 
LVL 13

Expert Comment

by:KarinLoos
ID: 18768069
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
 

Author Comment

by:tfewster500
ID: 18768982
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
 
LVL 13

Expert Comment

by:KarinLoos
ID: 18778472
e - (DataGridItemEventArgs) is a reference to the current row being bound.
e.Item.ItemIndex  == gives the index of this row within the datagrid.
0
 

Author Comment

by:tfewster500
ID: 18786395
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
 
LVL 13

Accepted Solution

by:
KarinLoos earned 250 total points
ID: 18788742
If you want to know the total number of rows, then u could just query : Datagrid.Items.Count.
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question