form detailview question

  • Thread starter Thread starter GS
  • Start date Start date
G

GS

in Windows form, I have Datagridview and detailview with the same binding
data manager. upon clicking the + in the navigator, the primary key field is
blank as expected, but I need to enable it for new record to let user to
fill it. On the other hand I don't want to allow change to the field for
existing record. so disable that on existing non new record. How do I do
that?


I notice the property of the fields are enabled in the form design, but
could not find any code for disable them.
 
Are you sure that allowing the user to fill the primary key is a good idea?
These are often left to the database and the insert statement will often
accept all fields _except_ the primary key which is often, by convention,
autogenerated.

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
Ordinarily, no.
this form deals with only a small number of named entries possibly less than
50.
the name field is only 16 characters.

and the users using this form is either developer or advanced users trying
to customize the application data extraction pattern.

I suppose I could generate primary key and have unique index on name
field.. however in the application the references are by name not by other
key for ease of use and maintenance by user.
 
I think that even with advanced users, the primary key is best left to some
automated process. User entered data tends to be subject to abuse, like
someone calling all their entries "fred" or such.

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
then it is the users wish to go against company policy to make meaningful
name. and he is going to suffer from the potential gain of meaning.
autogenerated key has no meaning neither. for alpha key in large table,
wide scatter of key values help performance but I double if small number of
similar key name make much difference in small tables of 100 entries or
less.

Furthermore, as long as the entry is not referenced, user will be allowed to
rename, change, delete. Once the entry is referenced , no change is allowed.
except for the admin person.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top