473,395 Members | 1,941 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Check items in GridView with JavaScript

Hi. Is it possible to iterate through the items in a GridView using
JavaScript on the client?

--
McGeeky
http://mcgeeky.blogspot.com

Jul 26 '06 #1
3 20649
You can iterate through the visible items (represented by the
DomElement tableRow) with the following snippet...

<script>
var tableElement = document.getElementById('idOfTable');
for (var i=0;i<tableElement.rows.count;i++){
var rowElem = tableElements.rows[i];
for (var x=0;x<rowElem.cells.count;x++){
var cell = rowElem.cells[x];
//cell is a reference to the cell object from where you can
get the checkbox element
}
}
</script>

Regards,
Tasos

McGeeky wrote:
Hi. Is it possible to iterate through the items in a GridView using
JavaScript on the client?

--
McGeeky
http://mcgeeky.blogspot.com
Jul 26 '06 #2
Great! Thanks for that. Is there are programmatic way to embed the ID of the
table in to the HTML file rather than hard coding it?

You can see that I am fairly new to this!

Thanks.

--
McGeeky
http://mcgeeky.blogspot.com
"Tasos Vogiatzoglou" <tv*****@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
You can iterate through the visible items (represented by the
DomElement tableRow) with the following snippet...

<script>
var tableElement = document.getElementById('idOfTable');
for (var i=0;i<tableElement.rows.count;i++){
var rowElem = tableElements.rows[i];
for (var x=0;x<rowElem.cells.count;x++){
var cell = rowElem.cells[x];
//cell is a reference to the cell object from where you can
get the checkbox element
}
}
</script>

Regards,
Tasos

McGeeky wrote:
Hi. Is it possible to iterate through the items in a GridView using
JavaScript on the client?

--
McGeeky
http://mcgeeky.blogspot.com

Jul 26 '06 #3
<%=dataGridInstance.ClientID%>

.... in the javascript ...

McGeeky wrote:
Great! Thanks for that. Is there are programmatic way to embed the ID of the
table in to the HTML file rather than hard coding it?

You can see that I am fairly new to this!

Thanks.

--
McGeeky
http://mcgeeky.blogspot.com
"Tasos Vogiatzoglou" <tv*****@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
You can iterate through the visible items (represented by the
DomElement tableRow) with the following snippet...

<script>
var tableElement = document.getElementById('idOfTable');
for (var i=0;i<tableElement.rows.count;i++){
var rowElem = tableElements.rows[i];
for (var x=0;x<rowElem.cells.count;x++){
var cell = rowElem.cells[x];
//cell is a reference to the cell object from where you can
get the checkbox element
}
}
</script>

Regards,
Tasos

McGeeky wrote:
Hi. Is it possible to iterate through the items in a GridView using
JavaScript on the client?
>
--
McGeeky
http://mcgeeky.blogspot.com
Jul 26 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: CSharpguy | last post by:
In my gridview I have 2 -3 template fields which are hyperlinks. I allow the user to print this grid. When the grid prints it also prints the links, how can I take the user to a print preview page...
1
by: jmdolinger | last post by:
Hi all, I'm a newbie to Atlas (and recently ASP.NET) after coming from a long Java background, also have done quite a bit with an Ajax.NET/ASP.NET 1.1 project, but it was basically all...
10
by: rn5a | last post by:
All the rows in a DataGrid, including the Header, are accompanied with a CheckBox. I want that when the CheckBox in the Header is checked, then all the CheckBoxes should automatically get checked....
2
by: HockeyFan | last post by:
Yesterday, I posted a question dealing with an issue of trying to reference (from javascript on the client side) an item within a Repeater. My code was hard-coded to use the actual ClientId, but...
3
by: =?Utf-8?B?SmFtZXMgUGFnZQ==?= | last post by:
I've a multiview with 3 views. on view 2 the user is presented with a check box list (items from database) at view 3 the user can review their selections and, either post to the database or go back...
2
by: wildman | last post by:
RE: Gridview textbox has data check without postback.. javascript? I have a gridview with a textbox. I can set the textbox to autopostback and check for a value in a prerender event to decide if...
2
by: bogdan | last post by:
Hi, Can a single GridView be 'connected' to DetailsView that renders itself differently based on the currently selected row? I have a GridView with rows that could be displayed in the same way...
1
Frinavale
by: Frinavale | last post by:
I'm working on an ASP.NET application using VB.NET for server side code. I have a GridView listing a bunch of stuff. Above the GridView I have a checkbox named "ChkBx_SelectAll". If this...
4
by: Peter | last post by:
I want to call a JavaScript on PageIndexChanged event, how do I do that? Thank You Peter
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.