PC Review


Reply
Thread Tools Rate Thread

Datagridview bound to a dataview

 
 
xanthviper@gmail.com
Guest
Posts: n/a
 
      23rd Jan 2007
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);
}

 
Reply With Quote
 
 
 
 
RobinS
Guest
Posts: n/a
 
      25th Jan 2007
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.
-----------------------------------------------
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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);
> }
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorted DataView, but unsorted datalist when bound to the dataview CodeMonkey Microsoft ASP .NET 1 4th Feb 2011 10:55 AM
Editing a DataGridView bound to a DataView ME Microsoft Dot NET 0 5th Jan 2007 04:48 AM
Editing a DataGridView bound to a DataView ME Microsoft Dot NET Framework 0 5th Jan 2007 04:48 AM
Adding rows to a bound table that is bound to DataGridView(DataSou =?Utf-8?B?S2V2aW4gQnVydG9u?= Microsoft Dot NET Framework Forms 2 22nd Jun 2006 06:05 AM
Re: PropertyManager.EndCurrentEdit() marks the bound dataview row as Modified even if the data in the bound control is unchanged Miha Markic [MVP C#] Microsoft ADO .NET 0 5th Jun 2004 11:19 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:45 AM.