简体   繁体   English

带有复选框的ASPxGridView错误

[英]ASPxGridView error with checkbox

I have one grid with checkbox. 我有一个带有复选框的网格。 Sometimes, when select row and click ADD button it's not work and debugger show me that haven't selected row. 有时,当选择行并单击“添加”按钮时,它不起作用,调试器会向我显示尚未选择的行。 This is a code: 这是一个代码:

protected void GridView_CustomCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomCallbackEventArgs e)
    {
        ASPxGridView grid = sender as ASPxGridView;
        List<object> ids = grid.GetSelectedFieldValues("ID");
        if (ids.Count > 0)
        { ......... }
}
SelectAllCheckbox _SelectAll;
    if (!(MyGV.Columns[0] is GridViewCommandColumn))
        {
            _SelectAll = new SelectAllCheckbox() { GridClientInstanceName = MyGV.ClientInstanceName };
            Common.AddCommandColumn(MyGV, 0, _SelectAll);
        }

Hope this helps. 希望这可以帮助。 Here the event RowDataBound is used. 这里使用事件RowDataBound。

private string chkGridColHeaderId = string.Empty;

protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Header)
        {
            CheckBox chkAll = (CheckBox)e.Row.FindControl("chkSelectAll");
            chkAll.Attributes.Add("onclick", "SelectAll(this.checked)");
            chkGridColHeaderId = chkAll.ClientID;

        }
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            CheckBox chkSelect = (CheckBox)e.Row.FindControl("chkSelect");

            chkSelect.Attributes.Add("onclick", "if(!this.checked)document.getElementById('" + chkGridColHeaderId + "').checked = false;");
        }

    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM