GridView / DetailsView and Insert

B

BJF

This should be easy, but I'm not grasping the concept...

I'm building a form to maintain a single-key SQL2005 table. I've created a
GridView control, generated the appropriate SQL statements via the wizard,
and have view / edit / delete working just fine.

As in any such function, I my users will need to add records to the table.
It appears that GridView doesn't have an Insert capability, even though I
see that I can add a 'New' button to the command column.

My ultimate goal is to have an empty row ready to accept new data for the
table (think about how that appears in Access or even SQL/Server). I've
added a DetailsView control to my page, and after much work, it 'sort of'
lines up with the columns in the GridView. Not real graceful, but it's part
of the way there.

Question 1 - is this the right way to go about this, or have I missed
something simple and obvious.

The next task will be to have a user select a record from that table, and
based on the key in that, maintain the records in a joined table. I've
built a second GridView, and connected it to the first. When the Select
button is clicked, the second section's GridView is populated, and all the
appropriate records appear. Again, I can View / Edit / Delete them no
problem.

I want to provide an Insert function similar to the one described above, but
with an enhancement - The key field (as provided by the first GridView)
can't be modified in the second section's Insert function - that has to be
the same as what was provided by the first GridView. All other fields can
be modified.

Question(s) 2 - Do I have to resort to another DetailsView or FormView here?
Is there anything special I need to do in the creation of the SqlDataSource
to allow that one field to be unchangeable?

Thanks in advance.
Ben
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,052
Latest member
LucyCarper

Latest Threads

Top