Alok
Fri Apr 23 12:52:41 CDT 2004
This is a multi-part message in MIME format.
------=_NextPart_000_0013_01C42921.19EBA630
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Could you not in the row changed event call RejectChanges() method of =
the dataset. It would rollback the errors.
regarding the first question could you handle the current cell changed =
event of the grid. Check if this row exists in the underlying table. If =
it does RejectChanges() else continue.
Check this article out in MSDN:
http://msdn.microsoft.com/library/default.asp?url=3D/library/en-us/vbcon/=
html/vbtskhandlingerrorswithwindowsformsdatagridcontrol.asp
HTH
"Megan" <megan.cameron@huntercontrol.com> wrote in message =
news:c5881b59.0404221452.7eb1a453@posting.google.com...
> Setting the primary key on the underlying DataTable does not stop the
> user from being able to modify the primary key field(s) within the
> DataGrid.
>=20
> I want the row changed event to check the modified data for errors.
> But if there are errors, I simply use the SetColumnError function to
> flag these as errors (ie: it doesn't stop errors from being entered,
> just lets the user know of the problem). I therefore then need the
> validating event to ensure that all errors have been fixed before the
> grid is left. It is only after this (ie: in the validated event) that
> the changes made in the grid get written back to the database.
>=20
> Hope this clears things up a little.=20
>=20
> "Alok" <alok_sathaye@pune.tcs.co.in> wrote in message =
news:<ug5F7aDKEHA.2880@TK2MSFTNGP10.phx.gbl>...
> > Megan,
> > Regarding the first issue..
> > Could you not set the primary key constraint on the dataset itself, =
instead
> > of changing the column styles.
> > For the second problem, i don't think you need to handle both the =
validating
> > and the row changed event. only the row changed should suffice.
> >=20
> > "Megan" <megan.cameron@huntercontrol.com> wrote in message
> > news:c5881b59.0404212240.6c3030de@posting.google.com...
> > > I'm currently trying to develop a solution containing a bound =
DataGrid
> > > that allows insert and update functions. I'm having 2 problems =
that
> > > i'd appreciate some help with.
> > >
> > > The first problem is where I have a primary key field that I don't
> > > want users to be able to modify. The obvious solution is to =
configure
> > > the column to be read only. However, then when a user tries to =
insert
> > > a record, that column is still read only and so nothing can be
> > > entered.
> > >
> > > The second problem i'm having is to do with validation. I have a
> > > RowChanging event on the underlying DataTable that validates the =
data
> > > and if there are any problems uses SetColumnError to flag the =
issue to
> > > the user. I also have a Validating event on the DataGrid that I =
use to
> > > confirm that there are no errors before a user can leave the grid. =
The
> > > problem is that the RowChanging and Validating events both fire at =
the
> > > same time. So that if a value is changed to an invalid value and =
then
> > > the grid is left, the value has not been flagged as an error when =
the
> > > Validating event runs.
> > >
> > > I hope I have explained these issues well enough. Any help or
> > > suggestions would be welcomed.
------=_NextPart_000_0013_01C42921.19EBA630
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1400" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff background=3D""><FONT face=3DArial =
size=3D2>Could you not in the=20
row changed event call RejectChanges() method of the dataset. It would =
rollback=20
the errors.<BR><BR>regarding the first question could you handle the =
current=20
cell changed event of the grid. Check if this row exists in the =
underlying=20
table. If it does RejectChanges() else continue.<BR><BR>Check this =
article out=20
in MSDN:<BR><A=20
href=3D"
http://msdn.microsoft.com/library/default.asp?url=3D/library/en-u=
s/vbcon/html/vbtskhandlingerrorswithwindowsformsdatagridcontrol.asp">http=
://msdn.microsoft.com/library/default.asp?url=3D/library/en-us/vbcon/html=
/vbtskhandlingerrorswithwindowsformsdatagridcontrol.asp</A><BR><BR>HTH<BR=
><BR>"Megan"=20
<megan.cameron@huntercontrol.com> wrote in message=20
news:c5881b59.0404221452.7eb1a453@posting.google.com...<BR>> Setting =
the=20
primary key on the underlying DataTable does not stop the<BR>> user =
from=20
being able to modify the primary key field(s) within the<BR>>=20
DataGrid.<BR>> <BR>> I want the row changed event to check the =
modified=20
data for errors.<BR>> But if there are errors, I simply use the=20
SetColumnError function to<BR>> flag these as errors (ie: it doesn't =
stop=20
errors from being entered,<BR>> just lets the user know of the =
problem). I=20
therefore then need the<BR>> validating event to ensure that all =
errors have=20
been fixed before the<BR>> grid is left. It is only after this (ie: =
in the=20
validated event) that<BR>> the changes made in the grid get written =
back to=20
the database.<BR>> <BR>> Hope this clears things up a little. =
<BR>>=20
<BR>> "Alok" <alok_sathaye@pune.tcs.co.in> wrote in message=20
news:<ug5F7aDKEHA.2880@TK2MSFTNGP10.phx.gbl>...<BR>> >=20
Megan,<BR>> > Regarding the first issue..<BR>> > Could you =
not set=20
the primary key constraint on the dataset itself, instead<BR>> > =
of=20
changing the column styles.<BR>> > For the second problem, i don't =
think=20
you need to handle both the validating<BR>> > and the row changed =
event.=20
only the row changed should suffice.<BR>> > <BR>> > "Megan"=20
<megan.cameron@huntercontrol.com> wrote in message<BR>> >=20
news:c5881b59.0404212240.6c3030de@posting.google.com...<BR>> > =
> I'm=20
currently trying to develop a solution containing a bound =
DataGrid<BR>> >=20
> that allows insert and update functions. I'm having 2 problems =
that<BR>>=20
> > i'd appreciate some help with.<BR>> > ><BR>> > =
> The=20
first problem is where I have a primary key field that I don't<BR>> =
> >=20
want users to be able to modify. The obvious solution is to =
configure<BR>>=20
> > the column to be read only. However, then when a user tries to =
insert<BR>> > > a record, that column is still read only and so =
nothing=20
can be<BR>> > > entered.<BR>> > ><BR>> > > =
The second=20
problem i'm having is to do with validation. I have a<BR>> > >=20
RowChanging event on the underlying DataTable that validates the =
data<BR>>=20
> > and if there are any problems uses SetColumnError to flag the =
issue=20
to<BR>> > > the user. I also have a Validating event on the =
DataGrid=20
that I use to<BR>> > > confirm that there are no errors before =
a user=20
can leave the grid. The<BR>> > > problem is that the =
RowChanging and=20
Validating events both fire at the<BR>> > > same time. So that =
if a=20
value is changed to an invalid value and then<BR>> > > the grid =
is=20
left, the value has not been flagged as an error when the<BR>> > =
>=20
Validating event runs.<BR>> > ><BR>> > > I hope I have =
explained these issues well enough. Any help or<BR>> > > =
suggestions=20
would be welcomed.</FONT></BODY></HTML>
------=_NextPart_000_0013_01C42921.19EBA630--