CheckBoxField columns in ASP.NET GridView are disabled even if ReadOnly set to false

前端 未结 2 984
梦如初夏
梦如初夏 2021-01-07 19:20

I have a GridView with two CheckBoxField columns. They both have ReadOnly property set to false, but html code generated for them has attribute disabled=\"disabled\". So the

2条回答
  •  心在旅途
    2021-01-07 19:39

    PhilPursglove solution works for me (even in a nested grivview). Thank you!

    My full code (modified to get also the grivview using the control tree, because i can't access the netest gridview directly because of dynamic creation):

    protected void Cb_IsApprovedByManagement_CheckChanged(object sender, EventArgs e)
        {
            CheckBox cb = (CheckBox)sender;
    
            // find the row we clicked the checkbox in by walking up the control tree
            GridViewRow selectedRow = (GridViewRow)cb.Parent.Parent;
            GridView gridView = (GridView)selectedRow.Parent.Parent;
    
            //  look up the DataKeys array
            int QuestionID_Current = (int)gridView.DataKeys[selectedRow.DataItemIndex].Value;
    
            // change value
            QuestionManager.ToggleActivity(QuestionManager.GetQuestion(QuestionID_Current));
    

提交回复
热议问题