Datagridview bound to a dataview

X

xanthviper

Pardon my ignorance here for I really can't find a direct answer to my
question concerning the DataGridView.

I have a Winform with a DataGridView on it. Its datasource is a
DataView. Life works great with the grid. I am able to sort, move
columns, and edit cells by clicking on the cell and making the change.

How do I update the changes to my DataView when I make a change to a
cell within the grid? I'm sure there is an easy answer to this and I
truly think i'm just having one of those days. Hopefully someone may
be able to point me in the right direction.

I am using .NET 2.0 and C#.

I appreciate your time.

Regards,

-Charlie



My Code Setup:



DataTable criteriaData;

private void SiteChooserControl_Load(object sender, System.EventArgs e)
{

criteriaData = subject.SiteSelectionCriteriaDataTable; //DataTable

gridSource = new DataView(criteriaData);
gridSource.AllowNew = false;
gridSource.AllowEdit = true;
gridSource.Sort = "SteNme";


AddHandlers();

this.grdSites.DataSource = gridSource;


}



protected void AddHandlers()
{
criteriaData.RowChanged += new
DataRowChangeEventHandler(criteriaData_RowChanged);
criteriaData.ColumnChanged += new
DataColumnChangeEventHandler(Criteria_ColumnChanged);
}
 
R

RobinS

The DataView is just a view of the original DataTable or DataSet.
It does not maintain its own copy of the data.

How you save the changes depends on the data source behind the
dataview.

Is criteriaData a datatable within a strongly typed dataset?
Does the strongly typed dataset have an update command object?

Generally speaking, one can invoke the Update method on the
table adapter used to fill the dataset in order to save the
changes in the detached dataset back to the database.

Hope this helps.
Robin S.
 

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