1

我有一个带有几个BoundFieldsin 的 gridview。我想做的是,一旦我选中(或取消选中)一个特定的复选框<asp:CheckBox ID="chkShowExtra" runat="server" AutoPostBack="True" oncheckedchanged="chkShowExtra_CheckedChanged" Text="Show extra details" Checked="False" />,它应该切换几个BoundFields. 我怎样才能做到这一点?

<asp:BoundField DataField="CUS_DatabaseEdition" DataFormatString="" HeaderText="Edition" SortExpression="CUS_DatabaseEdition" Visible="false" />
<asp:BoundField DataField="Offices" HeaderText="O" SortExpression="Offices" Visible="false">
    <ItemStyle HorizontalAlign="Right" />              
</asp:BoundField>
<asp:BoundField DataField="CUS_CustomerQuantity" HeaderText="Q" SortExpression="CUS_CustomerQuantity" Visible="false">
    <ItemStyle HorizontalAlign="Right" />              
</asp:BoundField>

我还发现了这个我认为会派上用场的活动。

protected void chkShowExtra_CheckedChanged(object sender, EventArgs e)
{

}

谢谢您的帮助!

4

1 回答 1

1

我用它来切换 ; 的可见性BoundFields

grdCategories.Columns[1].Visible = chkShowExtra.Checked;
grdCategories.Columns[2].Visible = chkShowExtra.Checked;
grdCategories.Columns[11].Visible = chkShowExtra.Checked;

活动内部chkShowExtra_CheckedChanged

于 2013-07-10T11:45:04.963 回答