We need a set of controls (textbox, dropDowns, etc), then, when the user fill that, he/she clicks the “Ok button”, and the insert is performed against the database, and we want to use the “insert command” contained into the sqldatasource that is already being used by the gridview control.
We usually think we need to use the Gridview to accomplish this task, but it’s not necessary at all.
If we have a sqldatasource like this:
The fill-in controls can be located outside the gridview, in any place in the page.
Also, create a button, give it an identity, and handle the click event as usual. After we click this button, we will perform the INSERT operation.
In the code behind, assuming the sqldatasource object you want to use is called SqlDataSource1 :
You can also add any data validation routine at this point.
Note that we called the insert method by hand after we set the values in the parameters as we needed.