Setting datasource to dataview or datatable?

J

John S.

I have a datagrid, it has a column with a checkbox (DataGridBoolColumn). On
the same form, there is also a textbox that is used to search the grid.
Here is the problem...

If I do datagrid.datasource = dataview then I can use the textbox to search
the grid via dataview.rowfilter. However, doing so makes the datagrid
checkbox column unaccessible (it is grayed out with a DBNull value). You
cannot set it programatically or manually (by clicking on it) to neither
true nor false. However, if I set datagrid.datasource = datatable, then I
can access the checkbox column properly, but then the search textbox stops
working since the dataview.rowfilter is no longer the datagrid's datasource.

How can I bind both the dataview and datatable to the datagrid at the same
time, so that I can use both the rowfilter, and checkbox column?

Any help greatly appreciated.

Thanks,
-John
 
J

John S.

Well I finally figured out the answer...

instead of initiating the DataView as such:

myDataView = new DataView(myDataTable,"",
ConfigurationSettings.AppSettings["DefaultSortColumn"],
DataViewRowState.OriginalRows);

I used the following instead:

DataViewManager dvm = new DataViewManager(myDataSet);
myDataView = dvm.CreateDataView(myDataTable);

Now the checkboxes are able to be un/checked both programatically and
manually, and I can use the dataGrid rowfilter option for searching.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top