Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8434587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:41:51+00:00 2026-06-10T06:41:51+00:00

I know this has been a very common and existing problem, but I have

  • 0

I know this has been a very common and existing problem, but I have tried many solutions from here, and I keep getting the same error.

Please do let me know where the Bug lies 🙁
And please edit/suggest if I am missing any information

Code:
XAML:

 <DataGrid Name="dtgQCNumbers"  
                              Width="409"
                              AutoGenerateColumns="False" 
                              ItemsSource="{Binding Path=.}"
                              CanUserResizeColumns="True" 
                              SelectionChanged="dtgQCNumbers_SelectionChanged" 
                              >

                          <DataGrid.Columns>
                            <DataGridCheckBoxColumn Header="IsChecked" Width="100" 
                                                                         Binding="{Binding Path=IsActive}"
                                                                        CanUserResize="True"/>                                 

                                                <DataGridTextColumn Header="QC_ID" Width="100" 
                                                                    Binding="{Binding Path=DataGridTextBox_QCList1}"
                                                                    CanUserResize="True"/>

                                                <DataGridTextColumn Header="Summary" Width="100"
                                                                    Binding="{Binding Path=DataGridTextBox_QCSummary}"
                                                                    CanUserResize="True"/>

                                                <DataGridComboBoxColumn Header="ControlOption" Width="100"
                                                                        SelectedItemBinding="{Binding Path=DataGridComboxBox_Control}"
                                                                        ScrollViewer.CanContentScroll="True"
                                                                        ScrollViewer.VerticalScrollBarVisibility="Auto"
                                                                        IsReadOnly="True"
                                                                        CanUserResize="True">
                                                <DataGridComboBoxColumn.ItemsSource>
                                                        <col:ArrayList>
                                                            <sys:String>AVS</sys:String>
                                                            <sys:String>DB</sys:String>
                                                                  <sys:String>AVS_DB</sys:String>
                                                        </col:ArrayList>
                                                    </DataGridComboBoxColumn.ItemsSource>

                                                </DataGridComboBoxColumn>

                        </DataGrid.Columns>
                         grid.ColumnWidth = new DataGridLength(100);

</DataGrid>

And the code behind for the data binding is:

private void OnInitialized()
  {
      string projectName = null;
      string crNumber = null;
      ComboBoxItem selectedProject;
      selectedProject = (ComboBoxItem)ddlProject.SelectedItem;
      projectName = selectedProject.Content.ToString();

      ActiveDirectoryWrapper.ApplicationUserData userData = Common.GetUserData(userName);

      string queryString;
      if (rdoMyQCs.IsChecked == true)
      {
          queryString = "Blalalalala";
      }
      else
      {
          queryString = "Blahblah";
      }

      Recordset qcIdSet = Common.queryTestDirector(projectName, queryString);
      qcIdSet.First();
      string colname = qcIdSet.get_ColName(0);

      _ds = new DataSet();
      DataTable table = new DataTable();
      _ds.Tables.Add(table);

      DataColumn c1 = new DataColumn("IsChecked", typeof(bool));
      table.Columns.Add(c1);
      DataColumn c2 = new DataColumn("QC_ID", typeof(string));
      c2.MaxLength = 500;
      table.Columns.Add(c2);
      DataColumn c3 = new DataColumn("QC_Summary", typeof(string));
      c3.MaxLength = 500;
      table.Columns.Add(c3);
      DataColumn c4 = new DataColumn("Control Option", typeof(string));
      c4.MaxLength = 500;
      table.Columns.Add(c4);
      while (!qcIdSet.EOR)
      {
          DataRow rw = table.NewRow();
          rw["IsChecked"] = true;
          rw["QC_ID"] = qcIdSet["BG_BUG_ID"].ToString();
          rw["QC_Summary"] = "";
          rw["Control Option for Deployment"] = "AVS_DB";
          table.Rows.Add(rw);
          qcIdSet.Next();
      }

      dtgQCNumbers.DataContext = _ds.Tables[0];
      throw new NotImplementedException();
  }

I keep on getting the error “Items collection must be empty before using ItemsSource”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T06:41:52+00:00Added an answer on June 10, 2026 at 6:41 am

    Why in the world would you place a C# string in your DataGrid.Items?

        </DataGrid.Columns>
        grid.ColumnWidth = new DataGridLength(100);
    </DataGrid>
    

    It’s not really surprising that you would get that error…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this question has been asked many times, but here are my specific
I know this has been asked many times but i'm yet to find a
I know this has been asked many times before, but i still can't seem
i know this question has been asked here but i am stuck with this
I thought this could've been a common question, but it has been very difficult
I know this question has been asked many times and we have gotten this
I know this is a pretty common problem but any of the solutions I
I know my issue is very common and similar types has been asked many
I know this has been asked a lot, but I have a server-side custom
My very first post here! I have been using this site for many years

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.