Thursday, 16 May 2013

Gridview SQL dataSource

Follow the above post and perform all the steps until you reach Figure-4. Here you will see 'Advanced...' button. Click it. (Figure-1)

Figure-1

Note: There is a possibility that you will see "Generate INSERT, UPDATE and DELETE statements" option disabled. The reason is, you do not have a primary key column in your database table. In current scenario, i have created ID as primary key column therefore the option is enabled.

Check the checkbox and click OK > Next > Finish.


Observe the changes that were to the GridView1 and SqlDataSource1 controls in markup. Now while in Design / Split mode, select GridView1, a small arrow button will appear besides it, click it. Check  'Enable Editing' and 'Enable Deleting' checkboxes. (Figure-2)

Figure-2
Note: Unless you generate Select, Update and Delete statements for SqlDataSource, you will not get options for enabling these actions GridView.

Now switch to Source mode and observe the changes applied to GridView1 and SqlDataSource1controls. (Figure-3)


Figure-3
Now run the application and try Updating or Deleting records.


DONE!

No comments:

Post a Comment