By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,089 Members | 1,367 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,089 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Nov 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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.
--------------------
From: "Hajime Kusakabe" <go********@hotmail.com>
Subject: DataGridItemEventArgs.Item.Cells - How to find last cell?
Date: Thu, 23 Oct 2003 10:58:20 -0600
Lines: 12
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <Od**************@TK2MSFTNGP12.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: mail.msiincdirect.com 65.121.20.186
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:186097
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

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


Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.