I was never able to get the filter to work with the System.Windows.Forms.DataGrid.  
But I was able to get the filtering to work with a master detail dataset using the 
true database grid from http://www.componentone.com/

private DataSet m_dsGrid = null;
private const string MASTER_TABLE = "EmployeePunchSummary";
.


private void bindGrid()
{
    try

    {
        // Serviced component 
        Punch.EmployeePunchDetail epd = new Punch.EmployeePunchDetail();
        m_dsGrid = epd.getPunches(txtFromDate.Text, txtToDate.Text);
        // Bind the dataset to the grid using the default view of the master table
        c1TrueDBGrid1.DataSource = m_dsGrid.Tables[MASTER_TABLE].DefaultView;
        c1TrueDBGrid1.DataMember = MASTER_TABLE;
        .
        .

private void applyFilter (string filter)
{
    try
    {
        if (null != m_dsGrid) m_dsGrid.Tables[MASTER_TABLE].DefaultView.RowFilter = 
filter;
        .
        .

This allows for complex filters to be applied on the cached ds.

Thanks,

Mark Potter


-----Original Message-----
From: Potter, Mark S. 
Sent: Wednesday, October 13, 2004 3:19 PM
To: [EMAIL PROTECTED]
Subject: [ADVANCED-DOTNET] Master Detail With RowFilter


I wrote a little test app to try to get row filtering to work with a master detail 
hierarchical data set.
 
Has anyone done this?
 
private DataSet ds = null;

private void bindGrid()

{

    try

    {

        // Serviced component 

        Punch.EmployeePunchDetail emp = new Punch.EmployeePunchDetail();

        // returns a dataset with two data tables and one relation defining 
master-detail 

        ds = emp.getPunches(txtFromDate.Text, txtToDate.Text);

        // bind to master and detail grids (System.Windows.Forms.DataGrid), this works 
fine

        dataGridMaster.SetDataBinding(ds, "EmployeePunchSummary");

        dataGridDetail.SetDataBinding(ds, "EmployeePunchSummary.EmployeeDetail");

    }

    catch (SqlException ex)

    {

        showError(ex);

    }

}
 

private void applyFilter ()

{

    try

    {

        if  (ds != null)

        {

            ds.Tables["EmployeePunchSummary"].DefaultView.RowFilter = txtFilter.Text;

           // filter does not seem to work for hierarchical datasets, but works fine 
when a single table is bound to the grid

       }

    }

    catch (SqlException ex)

    {

    showError(ex);

    }


}


===================================
This list is hosted by DevelopMentor�  http://www.develop.com
Some .NET courses you may be interested in:

Essential .NET: building applications and components with CSharp
August 30 - September 3, in Los Angeles
http://www.develop.com/courses/edotnet

View archives and manage your subscription(s) at http://discuss.develop.com

===================================
This list is hosted by DevelopMentor�  http://www.develop.com
Some .NET courses you may be interested in:

Essential .NET: building applications and components with CSharp
August 30 - September 3, in Los Angeles
http://www.develop.com/courses/edotnet

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to