syntax error in c# using repeaters

Hi,
I have a repeater in my asp.net code which gets all the events in a particular month and then using the dates found in the database I have a nested repeater to search for all events in that date, then a further nested repeater searches to see if the events found have a value in a particular field.
I think its nearly working but i'm stuck with the syntax on the second repeater.

 foreach (RepeaterItem repeaterID in Repeaterday.Items)

i have an error that Repeaterday does not exist in the current context

I'm not sure what to change it to, i tried Dataset.Items which it doesnt like either

Please help!
Thanks
protected void Page_Load(object sender, EventArgs e)
    {
        object result = null;
        string monthID = Request["Month"];
 
        Monthfixtureslabel.Text = "Fixtures for " + monthID;
 
        OpenConnection();
 
        SqlCommand mySqlSelectMonth = new SqlCommand("exec usp_GetAllMonthFixtures @monthID", conn);
 
        mySqlSelectMonth.Parameters.Add("MonthID", SqlDbType.NVarChar);
        mySqlSelectMonth.Parameters["MonthID"].Value = monthID;
 
        mySqlSelectMonth.CommandType = CommandType.Text;
 
        SqlDataAdapter mySqlAdapterMonth = new SqlDataAdapter(mySqlSelectMonth); 
        
        DataSet MonthDataSet = new DataSet();
 
        mySqlAdapterMonth.Fill(MonthDataSet);
 
        RepeaterMonth.DataSource = MonthDataSet;
 
        RepeaterMonth.DataBind();
 
        int k = 0;
 
        foreach (RepeaterItem repeaterItem in RepeaterMonth.Items)
        {
            string date = MonthDataSet.Tables[0].Rows[k]["Date"].ToString();
 
            OpenConnection();
            {
                SqlCommand mySqlSelect = new SqlCommand("exec usp_GetTestMonthFixtures @monthID, @Date", conn);
 
                mySqlSelect.Parameters.Add("MonthID", SqlDbType.NVarChar);
                mySqlSelect.Parameters["MonthID"].Value = monthID;
                mySqlSelect.Parameters.Add("Date", SqlDbType.NVarChar);
                mySqlSelect.Parameters["Date"].Value = date;
 
                mySqlSelect.CommandType = CommandType.Text;
 
                SqlDataAdapter mySqlAdapter = new SqlDataAdapter(mySqlSelect); 
                
                DataSet DataSet = new DataSet();
 
                mySqlAdapter.Fill(DataSet);
 
                ((Repeater)(repeaterItem.FindControl("Repeaterday"))).DataSource = DataSet;
 
                ((Repeater)(repeaterItem.FindControl("Repeaterday"))).DataBind();
 
                int l = 0;
 
                foreach (RepeaterItem repeaterID in Repeaterday.Items)
                {
                    Guid tempID = (Guid) MonthDataSet.Tables[0].Rows[l]["ID"];
 
                    OpenConnection();
                    {
                        SqlCommand mySqlSelectAM = new SqlCommand("exec usp_GetMonthAllAMFixtures @ID", conn);
 
                        mySqlSelectAM.Parameters.Add("ID", SqlDbType.UniqueIdentifier);
                        mySqlSelectAM.Parameters["ID"].Value = tempID;
 
                        mySqlSelectAM.CommandType = CommandType.Text;
 
                        SqlDataAdapter mySqlAdapterAM = new SqlDataAdapter(mySqlSelectAM);
                        DataSet AMDataSet = new DataSet();
 
                        mySqlAdapterAM.Fill(AMDataSet);
 
                        if (AMDataSet.Tables[0].Rows.Count <= 0)
                        {
                            AMDataSet.Tables[0].Rows.Add(new object[] { "No events", "" });
                        }
 
                        ((Repeater)(repeaterItem.FindControl("RepeaterAM"))).DataSource = AMDataSet;
 
                        ((Repeater)(repeaterItem.FindControl("RepeaterAM"))).DataBind();
 
                    }
 
                    {
                        SqlCommand mySqlSelectPM = new SqlCommand("exec usp_GetMonthAllPMFixtures @ID", conn);
 
                        mySqlSelectPM.Parameters.Add("ID", SqlDbType.NVarChar);
                        mySqlSelectPM.Parameters["ID"].Value = tempID;
 
                        mySqlSelectPM.CommandType = CommandType.Text;
 
                        SqlDataAdapter mySqlAdapterPM = new SqlDataAdapter(mySqlSelectPM);
                        DataSet PMDataSet = new DataSet();
 
                        mySqlAdapterPM.Fill(PMDataSet);
 
                        if (PMDataSet.Tables[0].Rows.Count <= 0)
                        {
                            PMDataSet.Tables[0].Rows.Add(new object[] { "No events", "" });
                        }
 
                        ((Repeater)(repeaterItem.FindControl("RepeaterPM"))).DataSource = PMDataSet;
 
                        ((Repeater)(repeaterItem.FindControl("RepeaterPM"))).DataBind();
 
                    }
                    {
                        SqlCommand mySqlSelectClub = new SqlCommand("exec usp_GetMonthAllClubFixtures @ID", conn);
 
                        mySqlSelectClub.Parameters.Add("ID", SqlDbType.NVarChar);
                        mySqlSelectClub.Parameters["ID"].Value = tempID;
 
                        mySqlSelectClub.CommandType = CommandType.Text;
 
                        SqlDataAdapter mySqlAdapterClub = new SqlDataAdapter(mySqlSelectClub);
                        DataSet ClubDataSet = new DataSet();
 
                        mySqlAdapterClub.Fill(ClubDataSet);
 
                        if (ClubDataSet.Tables[0].Rows.Count <= 0)
                        {
                            ClubDataSet.Tables[0].Rows.Add(new object[] { "No events", "" });
                        }
 
                        ((Repeater)(repeaterItem.FindControl("RepeaterClub"))).DataSource = ClubDataSet;
 
                        ((Repeater)(repeaterItem.FindControl("RepeaterClub"))).DataBind();
 
                    }
                    CloseConnection();
 
                    l++;
 
 
                }
 
                CloseConnection();
 
                k++;
            }
        }
    }

Open in new window

CharlieDevAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jjardineCommented:
I see you access RepeaterDay   through the FindControl method above your call to your foreach loop.     I would say you have two options.

First is you could change your foreach loop to use ((Repeater)(repeaterItem.FindControl("Repeaterday"))).Items

Or
Create a variable for Repeater day,   set it equal to (Repeater)(repeaterItem.FindControl("Repeaterday")  
then update your foreach loop to that new variable.items.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CharlieDevAuthor Commented:
Great thanks :)
0
CharlieDevAuthor Commented:
cheers :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.