?
Solved

DataGrid OnItemBound - Determine Table Row

Posted on 2007-03-21
7
Medium Priority
?
292 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

764 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