• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 681
  • Last Modified:

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

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
wilcor14
Asked:
wilcor14
  • 3
  • 2
1 Solution
 
john_steedCommented:
Hi,

out of curiosity, why would you want to do that ?
0
 
wilcor14Author Commented:
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
 
john_steedCommented:
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
 
john_steedCommented:
in the iteration first check on this
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
0
 
wilcor14Author Commented:
This is what I was looking for:

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

thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now