如何在javascipt中获取gridview选择的索引 [英] How to get the gridview selected index in javascipt
本文介绍了如何在javascipt中获取gridview选择的索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在javascipt中获取gridview选择的索引
i有一个gridview,每行有n行,带有两个复选框
by检查第一个复选框我必须启用第二个复选框,我需要首先选择gridview索引
提前谢谢
How to get the gridview selected index in javascipt
i have a gridview with n number of rows each row with two checkboxes
by checking the first check box i have to enable the second checkbox fro that i need selected index of gridview first
Thanks in advance
推荐答案
您好Yedhuvamshi,
尽管我理解您的问题,但您必须在Gridview的RowCreated事件中编写以下代码行: -
Hi Yedhuvams
As much I understand your problem, you have to write the following lines of code in RowCreated event of your Gridview:-
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onclick", String.Format("EnableCheckBox({0});",e.Row.RowIndex));
}
然后在你的Javascript代码中: -
function
And then in your Javascript code:-
function
EnableCheckBox(vRowIndex)
{
// write your code to check the second check box
}
假设第一个复选框有一个id chk 。
然后在这里你可以做什么:
Suppose the first check box has an id chk.
then here what you could do:
chk.Attributes.Add("onclick","getindex(this.id)")
and then
function getindex(id)
{
var index = document.getElementById(id).selectedIndex;
}
请检查一下。
pls check this.
这篇关于如何在javascipt中获取gridview选择的索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文