DataGridItemEventArgs.Item.Cells - How to find last cell?

  • Thread starter Thread starter Hajime Kusakabe
  • Start date Start date
H

Hajime Kusakabe

I made a datagrid and it contains several columns.
The number of columns depend on what users select from a dropdown list.
Therefore the number of columns changes.

I would like to find the last item (or last cell number) from the datagrid.
Is there a way to find the last cell number? (Something like "ubound"
function for array).

Thanks.
Haji
 
Hi Hajime,

Wherever you put your code to add columns to the datagrid, add the
following after this code. This may or may not work depending on how you
add the columns. Experiment to see if it works for you.
Dim i As Integer = DataGrid1.Columns.Count

Otherwise, the following should work every time. Place this code in either
the ItemCreated or the ItemDataBound events.
Dim i As Integer = e.Item.Cells.Count

---
I hope this helps.

Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computer’s security.

This posting is provided "AS IS", with no warranties, and confers no rights.


--------------------
 
Back
Top