Solved

DataGrid OnItemBound - Determine Table Row

Posted on 2007-03-21
7
279 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
If you want to know the total number of rows, then u could just query : Datagrid.Items.Count.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

763 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now