无法获取GridView控件中的javascript中选定行的索引 [英] Unable to get selected row index of gridview in javascript
本文介绍了无法获取GridView控件中的javascript中选定行的索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一定的行/列,每一行的编辑按钮,一个gridview。当点击编辑按钮,它会打开一个文本框和一个按钮的弹出窗口。我想知道所选行上的弹出内部的按钮点击的索引。我加code像这样
I have got a gridview with certain rows/columns and an edit button for each row. When the edit button is clicked, it opens a popup window with a textbox and a button. I want to know the index of the selected row on click of the button inside the popup. I added code like so
var table = document.getElementById('<%= gvTimeSlots.ClientID%>');
var Row;
for (var i = 1; i < table.rows.length; i++) {
Row = table.rows[i];
alert(Row);
}
但警报给了我未定义。缺少什么我在这里?
But the alert gives me "Undefined". What am I missing here?
推荐答案
这是我的修补程序。
function GetSelectedRow(lnk) {
var row = lnk.parentNode.parentNode;
var rowIndex = row.rowIndex - 1;
alert("RowIndex: " + rowIndex);
return false;
}
我打电话这个功能的的OnClientClick 链接按钮的事件。
<asp:TemplateField HeaderStyle-HorizontalAlign="Left" HeaderStyle-Width="10%" Visible="true">
<ItemTemplate>
<asp:LinkButton ID="lnkViewTimeSlots" runat="server" Text="Edit" ForeColor="Blue" OnClick="lnkViewTimeSlots_click" OnClientClick="return GetSelectedRow(this); javascript:shouldsubmit=true;" CausesValidation="false" Style="padding: 0px; margin: 0px;"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
这篇关于无法获取GridView控件中的javascript中选定行的索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文