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
35
Virtual Scrolling TemplateDataField
posted

I have a TemplateDataField within my Grid, which contains a single control as checkbox.

On certain user actions, I wish to loop through the grid and check all of the checkboxes contained within the TemplateDataField's.

 

I am having difficulty doing this, as it seems that when Virtual Scrolling is used, controls are rendered to the page in batches (based on the grid size, but in my case it is 49), so within my loop, FindControl is actually throwing an error.

Here is my loop:

for (int i = 0; i < webdgRequest.Rows.Count; i++)
        {
            var checkBox = (CheckBox) webdgRequest.Rows[i].Items[1].FindControl("checkervalue");
            if (checkBox.Enabled && checkBox.Checked == false)
            {
                var itemid = (Label) webdgRequest.Rows[i].Items[0].FindControl("lblProcessID");
                var command =
                    new SqlCommand("Update ProcessLinks set CheckerValue = 1, CheckerValueUser = '" +
                                   HttpContext.Current.User.Identity.Name +
                                   "', CheckerValueDate = GETDATE() Where ID = " + itemid.Text);
                ExecuteStatement(command);
            }
        }

 

Does anyone know of a work around? This grid displays upto 4,000 records, so I really want to avoid turning off Virtual Scrolling if possible.

 

Kind Regards