我正在使用带有复选框的网格视图,我需要在检查网格视图中的任何复选框时从中创建一个表格行。我需要帮助才能使用 javascript 获取 gridview 的选定行。
GridView 源代码
<asp:GridView ID="GrdCustomer" runat="server" BorderColor="#999999" CellPadding="3"
ForeColor="Black" GridLines="Vertical" Width="640px" AllowPaging="True" AutoGenerateColumns="False"
OnRowDataBound="GrdCustomer_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="Select" ItemStyle-Width="50px">
<ItemTemplate>
<input id="selector" onclick="javascript:bindToList(this);selectCustomers();" runat="server" type="checkbox" />
</ItemTemplate>
<HeaderTemplate>
<input id="selector" onclick="javascript:SelectDeselectAllCheckboxes(this);selectCustomers(); " runat="server"
type="checkbox" />
</HeaderTemplate>
<ItemStyle Width="50px" HorizontalAlign="Center"></ItemStyle>
</asp:TemplateField>
<asp:BoundField DataField="Salutation" HeaderText="Salutation">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="Name" HeaderText="Client Name">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Email">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="Title" HeaderText="Title">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="Id" HeaderText="Id" />
</Columns>
<FooterStyle BackColor="#CCCCCC" />
<PagerStyle BackColor="#999999" ForeColor="Black" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="#CCCCCC" />
</asp:GridView>
在复选框检查状态下调用基本脚本(仅启动)
function selectCustomers() {
alert("Hey I'm over here!!!");
}