Solved

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

Posted on 2007-11-20
5
673 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 3

Accepted Solution

by:
john_steed earned 500 total points
ID: 20322825
Hi,

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

Author Comment

by:wilcor14
ID: 20322893
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
ID: 20322982
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
ID: 20322990
in the iteration first check on this
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
0
 

Author Comment

by:wilcor14
ID: 20323245
This is what I was looking for:

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

thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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…

717 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