GridView / DetailsView and Insert

Discussion in 'ASP .Net Web Controls' started by BJF, Dec 16, 2005.

  1. BJF

    BJF Guest

    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
    --
    BJF, Dec 16, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. cannontrodder
    Replies:
    1
    Views:
    711
    cannontrodder
    Jul 25, 2006
  2. Replies:
    1
    Views:
    1,067
    Mark E. Hansen
    Oct 11, 2006
  3. et
    Replies:
    0
    Views:
    871
  4. eagle

    Insert & Insert/Repeat buttons in a detailsview

    eagle, Jul 12, 2007, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    1,033
    eagle
    Jul 12, 2007
  5. Feege
    Replies:
    0
    Views:
    432
    Feege
    Dec 20, 2005
Loading...

Share This Page