How to easily insert row in GridView with SqlDataSource?

Asp.Net 2.0 GridView control is very powerful control. Developers at Microsoft really did a great job when designing it. Its like Swiss Army knife for selecting, editing, sorting, paging and displaying data. Combined with various DataSource controls (ObjectDataSource, SqlDataSource) it helps you execute most of your Read, Update and Delete operations without writing a single line of code. Off course, nothing is perfect. For example, creating new data is is one common task that is not so simple to accomplish with GridView. Since there is InsertCommand property in DataSource controls that we can set to insert data, there is no reason not to use it with GridView to insert new data, just like we use DeleteCommand to delete data. For some strange reason there is no built-in way to do this, but there are always workarounds check out this link

No comments:

Post a Comment