Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

EditCommandColumn DataGrid with empty row

Status
Not open for further replies.

wallaceoc80

Programmer
Jul 7, 2004
182
GB
Is there any way I can add an extra row to a DataGrid when the user clicks on Edit so that a new row can be added if the user wants to?

If so what is the best way to do this?

Regards,

Wallace
 
One solution (and there may be a better one) is to simply add a new record to the datasource that the datagrid is bound to, and set the EditItemIndex to the very last item.

When I did this I was binding to an ArrayList of custom business-entity objects, so it was a simple thing to just create a new instance of one of my objects, add it to the collection I was binding to, and re-bind the DataGrid setting the EditItemIdex to the count of the collection minus 1.

Doing this may or may not be a little trickier if you are just using DataTables - (can't remember - haven't used those in a while).



Greetings,
Dragonwell
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top