3
我想創建一個ASP.NET頁面上的動態Gridview,我有多行,並添加了CheckBox列。ASP.NET隱藏GridView行與複選框
<body>
<h1>Alerts</h1>
<form id="form1" runat="server">
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:KiwiLogConnectionString %>" SelectCommand="SELECT * FROM [Syslogd]
GROUP BY MsgHostname, MsgDate, MsgTime, MsgPriority, MsgText"></asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="3" DataSourceID="SqlDataSource1" ForeColor="#333333" AllowPaging="True" PageSize="15">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:TemplateField >
<ItemTemplate >
<asp:CheckBox ID ="Checkbox" runat="server"/>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="MsgDate" HeaderText="Datum" SortExpression="MsgDate" ItemStyle-Wrap="false" >
<ItemStyle Wrap="False"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="MsgTime" HeaderText="Tijd" SortExpression="MsgTime" ItemStyle-Wrap="false" >
<ItemStyle Wrap="False"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="MsgPriority" HeaderText="Priority" SortExpression="MsgPriority" ItemStyle-Wrap="false" >
<ItemStyle Wrap="False"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="MsgHostname" HeaderText="Hostname" SortExpression="MsgHostname" ItemStyle-Wrap="false" >
<ItemStyle Wrap="False"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="MsgText" HeaderText="Message" SortExpression="MsgText" />
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
<asp:Button ID="btn_update" runat="server" OnClick="btn_update_Click" Text="Update" />
</form>
</body>
如果該複選框被選中並且單擊「更新」按鈕,我希望這些行被隱藏。我怎樣才能做到這一點?
protected void btn_update_Click(object sender, EventArgs e)
{
}
gridview是由SQL數據庫構建的,所以它必須是動態的。非常感謝!
資本'V'in'.Visible',傻= = – jadarnel27 2013-03-13 13:02:52
@ jadarnel27固定,謝謝證明:D – tymeJV 2013-03-13 13:07:04
哈哈,沒問題。此外,您從未在您的示例中聲明「複選框」,並且「.Checked」屬性也應該大寫。您應該在發佈之前在IDE中檢查這些內容,以確保安全。 – jadarnel27 2013-03-13 13:10:27