0

I have a sqlite database connected to a DataTable and the DataTable is bound to a datagridview.

I have a column named Event Type and i want to separate the Event Types into two different datagridviews.

The first datagridview will contain all rows that have an Event Type other than "Exam" and the second datagridview will have ONLY rows that contain the Event Type "Exam".

I have been reading on filters but haven't got anything to work and am not sure the best way to approach this problem.

The datagridviews are both bound to the same DataTable. I am fairly new to programming and am working on a personal app just trying to get used to c# and .NET.

Does anyone have any ideas on how to solve this problem?

This code gave me the most progress, except that it makes all the current rows just go to blanks. It doesn't save it to the database or anything.

    public void EventTypeFilter()
    {
        var myDataView = dataSourceDataSet.Event.DefaultView;
        EventsDataGridView.DataSource = myDataView;
        myDataView.RowFilter = string.Format("EventType <> '{0}'", "Exam");   
    }
4

1 回答 1

1

Update:

public void EventTypeFilter()
{
    DataTable table = dataSourceDataSet.Tables["TableName"];        
    table.DefaultView.RowFilter = string.Format("EventType <> '{0}'", "Exam");
    EventsDataGridView.DataSource = table;           
}
于 2012-08-14T14:07:56.723 回答