Javascript retrieves the row content selected by the gridview
Source: Internet
Author: User
To select these items, you must first find the rows to be selected, as shown below:
VaR table = Document. getelementbyid ("<% = gridview1.clientid %> ");
VaR rowindex = 0;
For (VAR I = 1; I <Table. Rows. length; I ++)
{
VaR input = table. Rows [I]. cells [0]. getelementsbytagname ("input") [0]. checked;
If (input = true)
{
Rowindex = I;
Return rowindex;
}
}
Get the value in textbox
Table. Rows [rowindex]. cells [3]. getelementsbytagname ("input") [0]. Value
Get the value in lable
Table. Rows [rowindex]. cells [4]. getelementsbytagname ("span") [0]. innerhtml
The later. innerhtml can be replaced with. innertext, but the browser compatibility of. innerhtml is better.
(You should note that it is used. innerhtml or. innertext only displays information between <span> XXXX </span>, rather than the textbox label in <input value = "XXXX"> </input>. The disadvantage is that the page will not be refreshed once it is refreshed .)
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.