Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
50
FindControl always returns null
posted

I have a WebDataGrid that contains an ItemTemplate with one checkbox. The user can select any number of checkboxes and click on a button to save their selections. In the button's click event, I am attempting to loop through each row in my grid to determine which checkbox was selected. Everytime I try and find the checkbox control, it returns a null. I have tried the same thing in the InitializeRow event of the grid and I am able to find the control. What is wrong?

protected void btnDelete_Click(object sender, EventArgs e)
 {

        foreach (GridRecord gridRow in gridBrokerRelationships.Rows)
        {
            CheckBox chk = (CheckBox)gridRow.Items[gridBrokerRelationships.Columns["Delete"].Index].FindControl("chkDel");

            if (chk != null)
            {
                if (chk.Checked)
                {
                   
                }
            }
        }

}

  • 2426
    Suggested Answer
    posted

    Hi,

    There was an issue that was exhibiting this behavior around the timeframe of the post. Since then the issue has been fixed. I would recommend upgrading to the latest Service Release to resolve this.