DataGrid/SqlCeDataAdapter Question

G

Guest

Folks,

I have a DataGrid I've populated from a SqlCeDataAdapter. The DataGrid lives
on a Form, from which it is possible to get to a second Form allowing
creation of a new record in the table from which the SqlCeDataAdapter reads
(selects). When I close the second Form, I want the new record to appear in
the DataGrid. I can make this happen by clearing and re-filling (from the
adapter) the table which is the DataSource for the DataGrid, but I was
wondering if this is the correct approach. Should I use
SqlCeDataAdapter.InsertCommand and SqlCeDataAdapter.Update, instead?

A second, unrelated, question is, is it possible to configure the DataGrid
so that only an entire row can be selected, rather than individual cells?

Thanks,

Matthew Fleming
 
D

Darren Shaffer

On your first question, I would not use a SqlCeDataAdapter but rather
fill a DataTable with the initial rows to display, set the DataGrid's
datasource
equal to that DataTable, add rows to the DataTable (updating the underlying
SQLCE DB with insert or update statements as needed), etc. To refresh the
DataGrid, just reset it's datasource equal to the DataTable as the DataTable
changes. The SqlCeDataAdapter will not always generate usable insert
and update commands and this is a slow performing option for any signifncant
number of records.

Second, you simply respond to the MouseUp event on the DataGrid, inspect the
HitTestType to determine if a cell or row header has been selected, then
select
the entire row in code.
--
Darren Shaffer
..NET Compact Framework MVP
Principal Architect
Connected Innovation
www.connectedinnovation.com
 

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

Similar Threads

Updating a datagrid 2
SqlCeDataAdapter Commands 3
SQL Server CE DataGrid 2
Advice on Paging records 1
DataGrid 2
datagrid edit 2
Datagrid column size 1
[Q] SqlCeDataAdapter, not updating 5

Top