Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determining last row when data binding

Status
Not open for further replies.

Peppi

Programmer
Apr 9, 2001
205
CA
Hi,

I am binding data to a datagrid. In the ItemDataBound event, for the last DATA row (i.e. not the footer), I want to attach some JavaScript code to some of the elements. My problem is how to tell when I've reached the last row?

Thx.
 
you can make a static app variable that holds the row count when you get your data ... count the rows before you bind, set the count to that variable, then in the ItemDataBound event check and see if its the last row - use a counter for that i suppose. :)
 
declare a page level variable
Public Shared i As Integer

After the fill of the dataset
i = YourDS.Table(index or name).rows.count

ItemDataBound event of the grid
If i = e.Item.ItemIndex + 1 Then
Response.Write("Last Row of the DataGrid")

End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top