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

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
 
M

Mike Moore [MSFT]

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.


--------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top