Solved

Using Javascript, how do you find the number of rows in a datagrid?

Posted on 2007-11-20
5
668 Views
Last Modified: 2008-02-01
I am using vb.net 2.0 and I need to find the the # of rows in a datagrid? Currently I am using:

var ddl = document.getElementById('dgTopicSelection').id;
alert(ddl.lentgh);

but it's giving me the wrong number. Thanks in advance.
0
Comment
Question by:wilcor14
  • 3
  • 2
5 Comments
 
LVL 3

Accepted Solution

by:
john_steed earned 500 total points
Comment Utility
Hi,

out of curiosity, why would you want to do that ?
0
 

Author Comment

by:wilcor14
Comment Utility
I have a drop down in my datagrid and I am running a for loop to find the value of each drop down in each row of the datagrid. I am them collecting the values in a variable and passing it onto the server for processing. Hope this helps.
0
 
LVL 3

Expert Comment

by:john_steed
Comment Utility
you can use something like this to iterate through the rows in vb.net,

For Each item as DataGridItem in gridMain.Items
' do stuff
dim ddlcomponent as DropDownList = ctype(item.FindControl("ddlComponent"),(DropDownList))

Next
0
 
LVL 3

Expert Comment

by:john_steed
Comment Utility
in the iteration first check on this
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
0
 

Author Comment

by:wilcor14
Comment Utility
This is what I was looking for:

document.getElementById('dgTopicSelection').rows.length;

thanks
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

744 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

16 Experts available now in Live!

Get 1:1 Help Now