Solved

DataGrid OnItemBound - Determine Table Row

Posted on 2007-03-21
7
289 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 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
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.…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

696 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