Clark
2007-11-28 12:36:52 UTC
I have a relational SQLExpress database where data from a GridView is
updated. The update command query looks like:
UPDATE [Readings] SET [Date]=@Date, [Reading]=@Reading, [User_ID]=@User_ID,
[Category_ID]=@Category_ID, [ItemsTracked_ID]=@ItemsTracked_ID WHERE
[ReadingsID]=@ReadingsID
The Category_ID and ItemsTracked_ID are the foreign keys from the Categories
and ItemsTracked tables that are displayed in the Readings table, and the
parameters are set to be the Selected Value of the Gridview.
When the gridview shows all the fields, including the Category_ID and
Items_TrackedID, and a user clicks the edit button to change a date or a
reading, and then clicks the Update button, everything works fine, the
record is updated.
But I dont want the user to see the Category_ID or the ItemsTracked_ID in
the gridview because those are not fields they should be trying to modify.
So I click the little expander arrow in the Gridview, Choose Edit Columns,
Choose (for example) the Category_ID column and set it Visible behavior to
False.
This causes the Category_ID field not to show when viewed in browser which
is what I want, but then when a record is selected and an update is
attempted, it fails saying "Cannot insert the value Null into Categories_ID"
What is the solution that would allow an update to work without the
Category_ID being visible in the Gridview?
Thanks in advance ---
updated. The update command query looks like:
UPDATE [Readings] SET [Date]=@Date, [Reading]=@Reading, [User_ID]=@User_ID,
[Category_ID]=@Category_ID, [ItemsTracked_ID]=@ItemsTracked_ID WHERE
[ReadingsID]=@ReadingsID
The Category_ID and ItemsTracked_ID are the foreign keys from the Categories
and ItemsTracked tables that are displayed in the Readings table, and the
parameters are set to be the Selected Value of the Gridview.
When the gridview shows all the fields, including the Category_ID and
Items_TrackedID, and a user clicks the edit button to change a date or a
reading, and then clicks the Update button, everything works fine, the
record is updated.
But I dont want the user to see the Category_ID or the ItemsTracked_ID in
the gridview because those are not fields they should be trying to modify.
So I click the little expander arrow in the Gridview, Choose Edit Columns,
Choose (for example) the Category_ID column and set it Visible behavior to
False.
This causes the Category_ID field not to show when viewed in browser which
is what I want, but then when a record is selected and an update is
attempted, it fails saying "Cannot insert the value Null into Categories_ID"
What is the solution that would allow an update to work without the
Category_ID being visible in the Gridview?
Thanks in advance ---
--
Clark
CHO, HomePage Doctor
www.homepagedoctor.com/ExpressionTutorials/Tutorials.htm
-------------------------------------------------------------------------------------------------
Clark
CHO, HomePage Doctor
www.homepagedoctor.com/ExpressionTutorials/Tutorials.htm
-------------------------------------------------------------------------------------------------