5 Replies - 1028 Views - Last Post: 06 June 2012 - 04:46 AM

#1 arun.m.mr  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 06-June 12

read all the column header text of a grid view using javascript

Posted 06 June 2012 - 04:03 AM

I need to read all the column header text of a grid view using java script.


function readgrid() {
var grid = document.getElementById('<%= GrdDynamic.ClientID %>');

alert(grid.rows[0].cells[0].innerHTML);
}

But I get the first column header only. I have 8 columns.I need to get all clolumn header values.
Is This A Good Question/Topic? 0
  • +

Replies To: read all the column header text of a grid view using javascript

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 2935
  • View blog
  • Posts: 7,687
  • Joined: 08-June 10

Re: read all the column header text of a grid view using javascript

Posted 06 June 2012 - 04:10 AM

View Postarun.m.mr, on 06 June 2012 - 01:03 PM, said:

But I get the first column header only.

that’s because you only request the first one (.cells[0])

try it on the table row instead.
Was This Post Helpful? 0
  • +
  • -

#3 arun.m.mr  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 06-June 12

Re: read all the column header text of a grid view using javascript

Posted 06 June 2012 - 04:16 AM

View PostDormilich, on 06 June 2012 - 04:10 AM, said:

View Postarun.m.mr, on 06 June 2012 - 01:03 PM, said:

But I get the first column header only.

that’s because you only request the first one (.cells[0])

try it on the table row instead.


thank you Mr.Dormilich for the post. But I'm using a dynamic grid view. At run time the number od columns may changed. How to find the number of columns of the gridview.?
Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 2935
  • View blog
  • Posts: 7,687
  • Joined: 08-June 10

Re: read all the column header text of a grid view using javascript

Posted 06 June 2012 - 04:41 AM

the table’s rows property has itself a property named length
Was This Post Helpful? 0
  • +
  • -

#5 arun.m.mr  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 06-June 12

Re: read all the column header text of a grid view using javascript

Posted 06 June 2012 - 04:44 AM

View PostDormilich, on 06 June 2012 - 04:41 AM, said:

the table’s rows property has itself a property named length


var n = document.getElementById("GrdDynamic").rows.length;

this will return the number of rows only. I need number of columns.
Was This Post Helpful? 0
  • +
  • -

#6 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 2935
  • View blog
  • Posts: 7,687
  • Joined: 08-June 10

Re: read all the column header text of a grid view using javascript

Posted 06 June 2012 - 04:46 AM

then use it on the cells property.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1