none
How to filter for rows that have no children? RRS feed

  • Question

  • How do I filter a ComboBox DataSource for DataTable rows that do not have child rows? Is there a way to do this using the DataTable's Select method? Currently, I'm using an expression column in the parent row that contains the count of related child rows, but I'm thinking there should be a way to handle this in the filter string of the DataTable Select method.

    Wednesday, July 2, 2008 8:06 PM

All replies

  • Perhaps you can use a expression in the rowFilter that is like this

    0 < Count(Child([RelationName]))

     

    Thanks

    Chris

     

    Thursday, July 3, 2008 12:16 AM
  •  Chris Robinson- MSFT wrote:

    Perhaps you can use a expression in the rowFilter that is like this

    0 < Count(Child([RelationName]))

     

    Thanks

    Chris

     

    I tried using your suggestion in many different ways and could never get it to work. Here's the statement:

     

    cmbCustomer.DataSource = dsOrderInfo.CUSTOMER.Select("Count(Child(rlCustomerOrder)) = 0")

     

    With that I get the error "Expecting a single column argument with possible 'Child' qualifier."

     

    When I try to insert the column name by which the tables are joined, it still doesn't work. I tried

     

    cmbCustomer.DataSource = dsOrderInfo.CUSTOMER.Select("Count(Cust_ID.Child(rlCustomerOrder)) = 0")

     

    and

     

    cmbCustomer.DataSource = dsOrderInfo.CUSTOMER.Select("Cust_ID.Count(Child(rlCustomerOrder)) = 0")

     

    with no success.

    Wednesday, July 9, 2008 9:16 PM
  •  

    You would not put it on the select statement. I would just set the RowFilter property on the DataView. I am assuming that cmbCustomer is a DataView. Perhaps you can try this

     

    DataView view = dsOrderInfo.CUSTOMER.DefaultView;

    view.RowFilter = "0 < Count(Child([RelationName]))"

    cmbCustomer.DataSource = view

     

    For the relationName I would specify the string value of the relationship name for rlCustomerOrder. I don't understand how you can go Cust_ID.Count, count is a function that is used and isn't used in this way

     

    Thanks

    Chris

    Wednesday, July 9, 2008 10:06 PM