问题
I'm using checkbox to select the rows in the gridview. How do I insert the muliple selected rows into the table opening the connection for only one time.
回答1:
When you postback, read all the checked rows and put the data into a DataTable. You can then use a SqlBulkCopy object to push that DataTable into your database table.
回答2:
Using JS to write into hidden field when user (un)checks a checkbox or to perform ajax call to server with id checked row.
来源:https://stackoverflow.com/questions/4396018/bulk-insert-with-gridview-using-c-sharp-asp-net