【问题标题】:How to uncheck the header checkbox in WebDataGrid in C#如何在 C# 中取消选中 WebDataGrid 中的标题复选框
【发布时间】:2018-12-14 15:33:49
【问题描述】:

我有一个 WebDataGrid 和一个 UnboundCheckBoxField 列。我希望能够从后面的代码中选中和取消选中标题中的复选框,从而选择或取消选择所有项目。 有 WebDataGrid1.Columns["IsActive"].Header 但那里没有我可以设置的值。

【问题讨论】:

    标签: asp.net infragistics webdatagrid


    【解决方案1】:

    您的方法是正确的,只需将该列转换为UnboundCheckBoxField 并使用HeaderChecked 属性。

    代码 sn-p (C#):

    protected void button1_Click(object sender, EventArgs e)
    {
        UnboundCheckBoxField checkboxField = (WebDataGrid1.Columns[0] as UnboundCheckBoxField);
    
        checkboxField.HeaderChecked = !checkboxField.HeaderChecked;
    }
    

    代码 sn-p (aspx):

    <ig:WebDataGrid ID="WebDataGrid1" runat="server" Height="350px" Width="400px" AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
    <Columns>
        <ig:UnboundCheckBoxField Key="Check" HeaderChecked="true" Width="25px" />
        ...
    </Columns>
    <Behaviors>
        <ig:EditingCore>
            <Behaviors>
                <ig:CellEditing>
                </ig:CellEditing>
            </Behaviors>
        </ig:EditingCore>
    </Behaviors>
    

    GIF:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-20
      • 1970-01-01
      相关资源
      最近更新 更多