I have been researching about this the whole morning and never found a straight forward answer. I will not be giving codes on this post BUT I will however encourage you not to do this for 3 good reasons:
- Ask yourself again if you really need to do this, and why. Gridviews are only graphical representations of set(s) of data from databases and/or datasets. So, ofcourse, if you wanted to add a row to your gridview, add it up on the table on your database and use the DataBind() method to bind the grid again from its data source.
- Let the database do its job. It is easier to handle data transactions on the database rather than in codes.
- For example, you've managed to get your code working to insert into a gridview dynamically, what next? Would you want to overwrite the database table with you gridview? I am not exactly sure if you can do this but this is a very bad programming practice.