如何在gridview中通过复选框查找所选行的索引?

时间:2014-03-30 19:40:09

标签: c# asp.net

我有一个包含2列的gridview,然后cell[0]有复选框,cell[1]有数据 我想要勾选复选框并单击按钮删除,找到选中的复选框并删除该行。

 <asp:GridView ID="GridView1" runat="server"  AutoGenerateColumns="False" BackColor="White"
         BorderColor="Blue" BorderStyle="Solid" CellPadding="3" DataSourceID="SqlDataSource1"
         ForeColor="Black"  GridLines="Vertical" Width="656px" >
        <AlternatingRowStyle BackColor="#CCCCCC" />
        <Columns>
             <asp:TemplateField>

                 <ItemTemplate>

                     <asp:CheckBox  runat="server" />
                 </ItemTemplate>``
             </asp:TemplateField>
            <asp:BoundField DataField="picname" HeaderText="picname" SortExpression="picname" />
        </Columns>
        <FooterStyle BackColor="#CCCCCC" />
        <HeaderStyle BackColor="#99FF66" Font-Bold="True" ForeColor="Black" BorderColor="#006600" />
        <PagerStyle BackColor="#33CC33" ForeColor="#0066FF" HorizontalAlign="Center" BorderStyle="Dashed" />
        <RowStyle BackColor="Lime" />
        <SelectedRowStyle BackColor="#0066CC" Font-Bold="True" ForeColor="White" />
        <SortedAscendingCellStyle BackColor="#F1F1F1" />
        <SortedAscendingHeaderStyle BackColor="#808080" />
        <SortedDescendingCellStyle BackColor="#CAC9C9" />
        <SortedDescendingHeaderStyle BackColor="#383838" />
    </asp:GridView>

1 个答案:

答案 0 :(得分:0)