Home All Groups Group Topic Archive Search About

Newbie needs help with datagrid

Author
5 Jun 2006 6:15 PM
RBell
I have a datagrid control that allows the user to enter new values. The
datagrid is bound to a predefined dataset. If the user enters a value that is
already in the datagrid the following system generated message is displayed:

Error when committing the row to the original data store
-----------------------------------------------------------------
Column <column name> is constrained to be unique. Value <whatever> is
already present. Do you want to correct the value?
--------------------------------------------------
Yes    No

I want to have a custom event handler such that if a duplicate value is
found to already exist that rather than display the above message the
addition is automatically aborted and the row where the existing value
resides is selected.

It seems from searching the forums that this should be something that can be
done with the CurrencyManager but I cannot seem to find an example of how to
use the CurrencyManager in VB.Net.

If there is a better way other than the CurrencyManager please let me know.
Any help much appreciated!

Author
6 Jun 2006 6:00 AM
Cor Ligthert [MVP]
RBell,

There is not so much testing done automatic in the DataGrid, that this is
done, is probably that there is no other way.

The currencymanager will help you definitly not with this, at the moment
that you are inserting is this in fact pointing to the last row that is or
should be in a datatable.

This action is probably fired in a rowchange or endcurrentedit situation and
it violates the constraint about the primary key, but I don't know how to
intercept that event. (And am not curious enough about it to search for it).

Cor

Show quoteHide quote
"RBell" <RB***@discussions.microsoft.com> schreef in bericht
news:1DAC69AC-4D5E-4813-9B04-3A73BB38F433@microsoft.com...
>I have a datagrid control that allows the user to enter new values. The
> datagrid is bound to a predefined dataset. If the user enters a value that
> is
> already in the datagrid the following system generated message is
> displayed:
>
> Error when committing the row to the original data store
> -----------------------------------------------------------------
> Column <column name> is constrained to be unique. Value <whatever> is
> already present. Do you want to correct the value?
> --------------------------------------------------
> Yes    No
>
> I want to have a custom event handler such that if a duplicate value is
> found to already exist that rather than display the above message the
> addition is automatically aborted and the row where the existing value
> resides is selected.
>
> It seems from searching the forums that this should be something that can
> be
> done with the CurrencyManager but I cannot seem to find an example of how
> to
> use the CurrencyManager in VB.Net.
>
> If there is a better way other than the CurrencyManager please let me
> know.
> Any help much appreciated!
Author
6 Jun 2006 12:33 PM
RBell
Thanks for taking the time to reply. I can appreciate that you are not
curious enough to look into my problem. I however need to find a way to
handle this. Occasionally when the user the answers No to message I mentioned
it crashes the program.

Anyone have any insight into this??

Show quoteHide quote
"Cor Ligthert [MVP]" wrote:

> RBell,
>
> There is not so much testing done automatic in the DataGrid, that this is
> done, is probably that there is no other way.
>
> The currencymanager will help you definitly not with this, at the moment
> that you are inserting is this in fact pointing to the last row that is or
> should be in a datatable.
>
> This action is probably fired in a rowchange or endcurrentedit situation and
> it violates the constraint about the primary key, but I don't know how to
> intercept that event. (And am not curious enough about it to search for it).
>
> Cor
>
> "RBell" <RB***@discussions.microsoft.com> schreef in bericht
> news:1DAC69AC-4D5E-4813-9B04-3A73BB38F433@microsoft.com...
> >I have a datagrid control that allows the user to enter new values. The
> > datagrid is bound to a predefined dataset. If the user enters a value that
> > is
> > already in the datagrid the following system generated message is
> > displayed:
> >
> > Error when committing the row to the original data store
> > -----------------------------------------------------------------
> > Column <column name> is constrained to be unique. Value <whatever> is
> > already present. Do you want to correct the value?
> > --------------------------------------------------
> > Yes    No
> >
> > I want to have a custom event handler such that if a duplicate value is
> > found to already exist that rather than display the above message the
> > addition is automatically aborted and the row where the existing value
> > resides is selected.
> >
> > It seems from searching the forums that this should be something that can
> > be
> > done with the CurrencyManager but I cannot seem to find an example of how
> > to
> > use the CurrencyManager in VB.Net.
> >
> > If there is a better way other than the CurrencyManager please let me
> > know.
> > Any help much appreciated!
>
>
>