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.

Re: Datagrid Issues by Alok

Alok
Thu Apr 22 14:25:47 CDT 2004

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.

"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.



Re: Datagrid Issues by megan

megan
Thu Apr 22 17:52:51 CDT 2004

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.

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.

Hope this clears things up a little.

"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.
>
> "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.

Re: Datagrid Issues by Alok

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
&lt;megan.cameron@huntercontrol.com&gt; wrote in message=20
news:c5881b59.0404221452.7eb1a453@posting.google.com...<BR>&gt; Setting =
the=20
primary key on the underlying DataTable does not stop the<BR>&gt; user =
from=20
being able to modify the primary key field(s) within the<BR>&gt;=20
DataGrid.<BR>&gt; <BR>&gt; I want the row changed event to check the =
modified=20
data for errors.<BR>&gt; But if there are errors, I simply use the=20
SetColumnError function to<BR>&gt; flag these as errors (ie: it doesn't =
stop=20
errors from being entered,<BR>&gt; just lets the user know of the =
problem). I=20
therefore then need the<BR>&gt; validating event to ensure that all =
errors have=20
been fixed before the<BR>&gt; grid is left. It is only after this (ie: =
in the=20
validated event) that<BR>&gt; the changes made in the grid get written =
back to=20
the database.<BR>&gt; <BR>&gt; Hope this clears things up a little. =
<BR>&gt;=20
<BR>&gt; "Alok" &lt;alok_sathaye@pune.tcs.co.in&gt; wrote in message=20
news:&lt;ug5F7aDKEHA.2880@TK2MSFTNGP10.phx.gbl&gt;...<BR>&gt; &gt;=20
Megan,<BR>&gt; &gt; Regarding the first issue..<BR>&gt; &gt; Could you =
not set=20
the primary key constraint on the dataset itself, instead<BR>&gt; &gt; =
of=20
changing the column styles.<BR>&gt; &gt; For the second problem, i don't =
think=20
you need to handle both the validating<BR>&gt; &gt; and the row changed =
event.=20
only the row changed should suffice.<BR>&gt; &gt; <BR>&gt; &gt; "Megan"=20
&lt;megan.cameron@huntercontrol.com&gt; wrote in message<BR>&gt; &gt;=20
news:c5881b59.0404212240.6c3030de@posting.google.com...<BR>&gt; &gt; =
&gt; I'm=20
currently trying to develop a solution containing a bound =
DataGrid<BR>&gt; &gt;=20
&gt; that allows insert and update functions. I'm having 2 problems =
that<BR>&gt;=20
&gt; &gt; i'd appreciate some help with.<BR>&gt; &gt; &gt;<BR>&gt; &gt; =
&gt; The=20
first problem is where I have a primary key field that I don't<BR>&gt; =
&gt; &gt;=20
want users to be able to modify. The obvious solution is to =
configure<BR>&gt;=20
&gt; &gt; the column to be read only. However, then when a user tries to =

insert<BR>&gt; &gt; &gt; a record, that column is still read only and so =
nothing=20
can be<BR>&gt; &gt; &gt; entered.<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt; =
The second=20
problem i'm having is to do with validation. I have a<BR>&gt; &gt; &gt;=20
RowChanging event on the underlying DataTable that validates the =
data<BR>&gt;=20
&gt; &gt; and if there are any problems uses SetColumnError to flag the =
issue=20
to<BR>&gt; &gt; &gt; the user. I also have a Validating event on the =
DataGrid=20
that I use to<BR>&gt; &gt; &gt; confirm that there are no errors before =
a user=20
can leave the grid. The<BR>&gt; &gt; &gt; problem is that the =
RowChanging and=20
Validating events both fire at the<BR>&gt; &gt; &gt; same time. So that =
if a=20
value is changed to an invalid value and then<BR>&gt; &gt; &gt; the grid =
is=20
left, the value has not been flagged as an error when the<BR>&gt; &gt; =
&gt;=20
Validating event runs.<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt; I hope I have =

explained these issues well enough. Any help or<BR>&gt; &gt; &gt; =
suggestions=20
would be welcomed.</FONT></BODY></HTML>

------=_NextPart_000_0013_01C42921.19EBA630--