Welcome to the Xceed Community Sign in | Join | Help
Community Search  

iteration over datarows equivilent

Sort Posts: Previous Next
  •  05-07-2008, 10:41 PM Post no. 12065

    iteration over datarows equivilent

    How do I iterate over each row in the grid currently?

     

     

    Filed under:
  •  05-08-2008, 6:47 AM Post no. 12073 in reply to 12065

    Re: iteration over datarows equivilent

    Hi Val,

    You could try this out: 

                foreach (object item in TestGrid.Items)
                {
                    Xceed.Wpf.DataGrid.DataRow dr = TestGrid.GetContainerFromItem(item) as Xceed.Wpf.DataGrid.DataRow;
                }

    where TestGrid is your Xceed DataGridControl.

    Just one thing to take note, this method only returns the rows after the Grid is initialized and rendered. I tried looping through this during the initialization of the grid, and even though there are already the items in the datagrid, the datarow object was not yet created 

    Cheerios,

    Serene
     


    "ASCII and ye shall receive."
  •  05-08-2008, 12:16 PM Post no. 12095 in reply to 12073

    Re: iteration over datarows equivilent

    Actually this looks like it was what I wanted.  Thanks though, it pointed me in the right direction. 

    foreach (System.Data.DataRow dr in dgvCourses.Items)
    {

    if (dr != null)

    total += decimal.Parse(dr[4].ToString());

    }

View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.