Solved

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

Posted on 2007-11-20
5
672 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

Suggested Solutions

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to implement server side field validation and display customized error messages to the client.
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…

733 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