I have tried various methods to retrieve the checked items from the CheckboxList, but have failed to do so. I've searched google but have had little luck there as well. Most of the examples given online talk about CheckboxList.Items[i].Select or Checkboxlist.SelectedItem, but those methods aren't really useful in my case, because once you click on a button or something else, the CheckboxList loses focus. So at that point 'SelectedItem' is basically null.

Here's my code:

Code:
        private void insertEnquiry()
        {
            List<ECMS_Enquiry> objECMS_Enquiry = new List<ECMS_Enquiry>();

            int i = 0;
            for (i = 0; i < chklstbxCourses.Items.Count; i++)
            {
                if (chklstbxCourses.Items[i].Selected)
                {
                    Response.Write("<script>alert('" + chklstbxCourses.Items[i].Text + "')</script>");

                    objECMS_Enquiry[i].Name = txtName.Text;
                    objECMS_Enquiry[i].Email = txtEmail.Text;
                    objECMS_Enquiry[i].Course = chklstbxCourses.Items[i].Text;
                    objECMS_Enquiry[i].Slot = drpdnlstSlot.Text;
                    objECMS_Enquiry[i].Availability = Calendar1.SelectedDate.ToString();
                    objECMS_Enquiry[i].Sponsorship = drpdnlstSponsorship.Text;
                }
            }

            int result = ECMS_Enquiry.Insert(objECMS_Enquiry);

            if (result == 0)
            {
                Response.Write("<script>alert('Enquiry inserted successfully')</script>");
            }
            else
            {
                Response.Write("<script>alert('Unable to insert enquiry')</script>");
            }
            
        }
Just so you know, 'ECMS_Enquiry' is a class that I've constructed separately.

I've used the same method that I've seen online since I don't know any other methods. Can someone help me?

If there's any more information that I haven't provided, please let me know. I shall provide it for you.

Thanks in advance.