Welcome to the Xceed Community | Help
Community Search  

How to get DataItem from DataRow

Sort Posts: Previous Next
  •  04-18-2008, 10:00 AM Post no. 11589

    How to get DataItem from DataRow

    Hi,

    I have set up a double click event handler on my grid's datarows.

    I can then cast the sender-object in my event handler to DataRow.

    But how do I get hold of the DataItem the DataRow is displaying?

     

    DataItem = DataRow.DataContext

     

    seems to be a solution.

    Is this the preferred way? Is this a stable solution?

    Or is there another way?

     

    Thanks,

    Michael.

  •  04-18-2008, 11:39 AM Post no. 11594 in reply to 11589

    Re: How to get DataItem from DataRow

    That is indeed a valid method and we don`t plan on changing this.

    If you need a more explicit way of retrieving the data item, there is another interface that exists, one that goes through the DataRow`s DataGridContext.

    DataGridContext rowContext = DataGridControl.GetDataGridContext( dataRow );

    object dataItem = rowContext.GetItemFromContainer( dataRow );

    The main advantage of this method is that you can pass ANY UI element that is part of the VisualTree of the Row or Cell to the GetItemFromContainer() method and that the appropriate Data Item will be returned.

    Marc Laroche
    Software Developer
    Xceed Software Inc.


    I don’t suffer from insanity, I enjoy every minute of it. - Unknown
    Filed under:
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.