Programming Tricks & Hacks

Manipulate GridView Rows, Cells, Cell Controls from JavaScript

Posted by kinjanshah on September 26, 2008

In one of the functionalities I was developing, I needed to integrate my GridView with JavaScript. I mean I was supposed to change the text in few cells of GridView. So, I dig it little bit and found out a way as I have shown below.

Accessing GridView rows/cells from JavaScript:

<script type=”text/javascript” language=”javascript”>

tblTable=document.getElementById(‘<<Client ID of the GridView>>’);
Cell=tblTable.rows[0].cells[0];
Cell.innerHTML=’Hurra!!!!! I have accessed the first row, first cell’;

</script>

Accessing GridView Rows/cells and Cell Control from JavaScript:
Isn’t it a great way to access GridView from JavaScript?

<script type=”text/javascript”>

tblTable=document.getElementById(‘<<Client ID of the GridView>>’);
Cell=tblTable.rows[0].cells[0];
FirstControl = Cell.childNodes[0];

</script>

Hope this will help you out.

About these ads

5 Responses to “Manipulate GridView Rows, Cells, Cell Controls from JavaScript”

  1. subashini said

    I too need some help regarding this…
    i obtained collection of checkboxes dynamically in a datalist which is in gridview.
    nw i require the count of checkboxes in a row of that grid.

    how can i get it..
    help me out!!

  2. programmatore…

    [...]Manipulate GridView Rows, Cells, Cell Controls from JavaScript « Programming Tricks & Hacks[...]…

  3. Shanon said

    What i do not realize is if truth be told how you are not actually much more well-favored than you might be now.
    You’re so intelligent. You already know thus considerably on the subject of this subject, made me in my view imagine it from numerous varied angles. Its like women and men are not interested unless it’s one thing to
    do with Woman gaga! Your individual stuffs excellent.
    Always maintain it up!

    Shanon

  4. Joss said

    I keep getting Cell is undefined, please any help would be welcome

  5. Tanja said

    This really is the 3rd post, of your blog I personally read through.
    And yet I enjoy this specific 1, “Manipulate GridView Rows, Cells,
    Cell Controls from JavaScript « Programming Tricks & Hacks”
    the most. Cya ,Rickey

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

%d bloggers like this: