Good morning,

I'm trying to update a DataSet based on data that has been modified in
a DataGridView. The DataSet isn't binded to the DataGridView because of
a couple conversions. (In this case, a time interval, or TimeSpan, is
stored as number of milliseconds). I haven't found an elegant way to
use the DataSource feature of the DataGridView and allow the
millisecond timespan representation to be displayed as a user-friendly
TimeSpan. To handle this disconnection, I'm simply creating a
DataTable that contains the data the way I want things to appear in the
DataGridView. This works well.

My problem is when I want to save the changes back to the database.
After the user makes a change to a cell and hits 'enter', the "New" row
below is highlighted (indicating that the change was performed on the
cell / row in question). Programatically, I read in the values from the
DataGridView.Rows[] collection. The values I find are the original
values from before the changes were made.

Is there some magic property I'm missing or certain way to get the
modified rows of a DataGridView? I have found nothing in the
documentation that sheds any insight. Should I just hold a reference to
a DataTable locally, bind THAT to the DataGridView, then just look at
the table for changes? Why aren't the Rows[] giving me my changes?

Thanks in a advance!
-Sean

Re: Modifications to DataGridView aren't reflected in Rows[] by Sean

Sean
Fri Jan 19 10:55:34 CST 2007

Found my problem. I had two instances of the DataGridView in the
context I was working. I had a property exposing the one I thought I
was working with. Turns out, it was the wrong one. ooops.

Working as designed! The Value property does in fact give me the new
value.

Cheers!
-Sean

On Jan 19, 10:45 am, "Sean Aitken" <sean.ait...@gmail.com> wrote:
> Good morning,
>
> I'm trying to update a DataSet based on data that has been modified in
> a DataGridView. The DataSet isn't binded to the DataGridView because of
> a couple conversions. (In this case, a time interval, or TimeSpan, is
> stored as number of milliseconds). I haven't found an elegant way to
> use the DataSource feature of the DataGridView and allow the
> millisecond timespan representation to be displayed as a user-friendly
> TimeSpan. To handle this disconnection, I'm simply creating a
> DataTable that contains the data the way I want things to appear in the
> DataGridView. This works well.
>
> My problem is when I want to save the changes back to the database.
> After the user makes a change to a cell and hits 'enter', the "New" row
> below is highlighted (indicating that the change was performed on the
> cell / row in question). Programatically, I read in the values from the
> DataGridView.Rows[] collection. The values I find are the original
> values from before the changes were made.
>
> Is there some magic property I'm missing or certain way to get the
> modified rows of a DataGridView? I have found nothing in the
> documentation that sheds any insight. Should I just hold a reference to
> a DataTable locally, bind THAT to the DataGridView, then just look at
> the table for changes? Why aren't the Rows[] giving me my changes?
>
> Thanks in a advance!
> -Sean


Re: Modifications to DataGridView aren't reflected in Rows[] by RobinS

RobinS
Fri Jan 19 15:52:16 CST 2007

Congrats! By the way, you can capture the Format and Parse events
on the cells of the datagrid for that field you want special formatting
on.
These events sit between pulling the data from the data source and
outputting the data into the grid cell. So in one direction, you can
take the number and format it; in the other direction, you can unformat
it and store it.

Robin S.
-----------------------------
"Sean Aitken" <sean.aitken@gmail.com> wrote in message
news:1169225734.051736.197350@a75g2000cwd.googlegroups.com...
> Found my problem. I had two instances of the DataGridView in the
> context I was working. I had a property exposing the one I thought I
> was working with. Turns out, it was the wrong one. ooops.
>
> Working as designed! The Value property does in fact give me the new
> value.
>
> Cheers!
> -Sean
>
> On Jan 19, 10:45 am, "Sean Aitken" <sean.ait...@gmail.com> wrote:
>> Good morning,
>>
>> I'm trying to update a DataSet based on data that has been modified
>> in
>> a DataGridView. The DataSet isn't binded to the DataGridView because
>> of
>> a couple conversions. (In this case, a time interval, or TimeSpan, is
>> stored as number of milliseconds). I haven't found an elegant way to
>> use the DataSource feature of the DataGridView and allow the
>> millisecond timespan representation to be displayed as a
>> user-friendly
>> TimeSpan. To handle this disconnection, I'm simply creating a
>> DataTable that contains the data the way I want things to appear in
>> the
>> DataGridView. This works well.
>>
>> My problem is when I want to save the changes back to the database.
>> After the user makes a change to a cell and hits 'enter', the "New"
>> row
>> below is highlighted (indicating that the change was performed on the
>> cell / row in question). Programatically, I read in the values from
>> the
>> DataGridView.Rows[] collection. The values I find are the original
>> values from before the changes were made.
>>
>> Is there some magic property I'm missing or certain way to get the
>> modified rows of a DataGridView? I have found nothing in the
>> documentation that sheds any insight. Should I just hold a reference
>> to
>> a DataTable locally, bind THAT to the DataGridView, then just look at
>> the table for changes? Why aren't the Rows[] giving me my changes?
>>
>> Thanks in a advance!
>> -Sean
>