我有一個數據網格,並有一個複選框,它是每一行中的模板。 假設我處於其中一個複選框的CheckedChanged事件中。有什麼辦法可以告訴在複選框的datagrid的哪一行?什麼行索引在數據網格中有模板複選框?
0
A
回答
0
好,我找到了一個巧妙的解決辦法:)在的CheckedChanged事件我只是寫了以下內容:
((GridViewRow)((Control)sender).Parent.Parent).DataItemIndex;
1
你可以通過Parent屬性,儘管你必須做一些像chk.Parent.Parent等等。我不知道當前行有多少家長引用是...
HTH。
0
嘗試這樣:
<script language="javascript" type="text/javascript">
function rowno(rowindex) {
var gridViewCtlId = document.getElementById("<%=GridView2.ClientID %>").rows[rowindex].cells[1].innerText;
alert('you clicked on ' + gridViewCtlId);
}
</script>
<asp:GridView ID="GridView2" runat="server" OnRowDataBound="GridView1_RowDataBound1" PageSize="5">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<%--<asp:Button ID="Button1" runat="server" Text="Button" />--%>
<asp:CheckBox ID="CheckBox1" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
中的.cs
protected void GridView1_RowDataBound1(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
CheckBox delete = (CheckBox)e.Row.Cells[0].Controls[1];
delete.Attributes.Add("onclick", "javascript:rowno(" + count + ")");
count++;
}
}
相關問題
- 1. 如何獲得所選複選框的行索引網格GXT
- 2. as3數據網格中的複選框
- 3. 複選框在數據網格渲染
- 4. 檢查網格面板中的所有複選框在extjs
- 5. C#ASP.NET數據網格複選框
- 6. 數據網格複選框自動化
- 7. 帶複選框的Extjs網格面板
- 8. 獲取數據網格的行索引
- 9. 如果在數據網格中選中複選框,獲取整行值C#
- 10. 數據網格handlebars模板
- 11. 數據網格模板[WPF]
- 12. WPF數據網格模板
- 13. 如何使用複選框在flex中選擇數據網格中的所有行或選定行
- 14. 選中使用標題複選框在asp.net網格中的所有複選框
- 15. 從wpf數據網格中的複選框中選擇值
- 16. R數據框索引中的比較有什麼作用?
- 17. 在qml中獲取選中複選框的行索引
- 18. kendo mvc網格編輯器模板與複選框列表
- 19. CheckboxSelectionModel ExtJs中的網格:無法選中網格面板中的複選框,選中標題複選框時將檢查所有行
- 20. 從表格中檢索POST複選框數據(如果存在)
- 21. 網格中的模板行
- 22. WPF:選中/取消選中位於gridview單元格模板中的複選框的所有複選框?
- 23. 網格視圖選中複選框關閉數據庫值
- 24. 如何將選中的網格複選框插入數據庫
- 25. 網格複選框選擇
- 26. 柔性選擇/取消選擇在數據網格的所有複選框
- 27. EXTJS - 2帶複選框模型的網格 - 如果選中其他網格中的相應複選框,則禁用一個網格中的複選框?
- 28. 帶有複選框的ngTable不會選中網格上的所有複選框
- 29. 選中複選框+網格面板與ExtJS的4
- 30. 如何在wpf數據網格中按索引獲取行
這幾乎完全是布萊恩所說的做的...... – Josh 2010-09-21 13:37:16