0

I have an ASP.NET Datagrid with several text boxes and drop down boxes inside it. I want to read all the values in the grid using a JavaScript function. How do i go about it?

2 Answers 2

2

Easily done with jQuery. I don't recall what kind of markup the Datagrid creates but basically something like this will work in Jquery

    $('#client_id_of_datagrid input, #client_id_of_datagrid select')
.each(function() {val = this.value; /* Do Stuff */})
Sign up to request clarification or add additional context in comments.

Comments

1

And here's an example using Microsoft AJAX framework:

var txts = $get('client_id_of_datagrid').getElementsByTagName('input');
var ddls = $get('client_id_of_datagrid').getElementsByTagName('select');

for(var i=0;i<txts.length;i++){
  if(txts[i].type==='text'){
    /* do stuff */
  }
}

for(var i=0;i<ddls.length;i++){
  /* do stuff */
}

And for no framework replace $get with document.getElementById. Really, jQuery is the best idea.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.