Tuesday, March 10, 2009

Edit/Update/Delete GridView automatically

There is an easy way to edit/delete/update rows in a GridView data control.

All you have to do is:

a) Configure SQLDataSource data-control.

b) Select a table.

c) Select column-field(s) including the primary-key column.

d) To the right, click on the Advanced button & select ‘Generate INSERT, UPDATE and DELETE statements’.

sqldatasource_auto_updatedeleteedit

c) Click Next; test-query & click Finish.

Now, go back to your GridView. On the smart-tag, select ‘Enable Editing’ and ‘Enable Deleting’.

gridview_ebanle_autohandling

That's it. Now run the page, try to editing/updating/deleting the records. Leave everything to SQLDataSource. You are hands free now.

How easy, isn't it ?

No comments:

 
Best viewed in Internet Explorer 8.