Results 1 to 4 of 4

Thread: DataGrid - prohibiting addition of records

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Location
    San Diego - California
    Posts
    251

    DataGrid - prohibiting addition of records

    I have a datagrid which is bound to a DataTable.

    I would like the user to be able to edit the data in the grid but not be able to add a new record.

    If I set the ReadOnly property to false I see that the Grid adds an extra row at the end for record addition.


    How does one prevent this extra row. Is there some method to prevent additions to the DataTable.

  2. #2
    Addicted Member wolfofthenorth's Avatar
    Join Date
    Jan 2001
    Location
    Tatooine
    Posts
    169
    You could check to see if RowState = DataRowState.Modified and then update only with those rows.

    I "think" something like this might work.

    myDataAdapter.Update(myTable.GetChanges(DataRowState.Modified).Select)

    That which does not kill us, only makes us stronger.

  3. #3
    New Member
    Join Date
    Jul 2002
    Location
    michigan
    Posts
    2
    Give this a try:

    Instead of binding to the datatable directly use a dataview which has an allownew property you can change to false.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Location
    San Diego - California
    Posts
    251
    I used the defaultDataview and the allownew property, and it worked great.

    Thanks once again for all your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width