How to insert a record using a grid view control

How to insert a record using a Grid View control

Reference:

Add the page and the necessary controls for your db insert to take place. The, in the code behind, add the following code to the buttons click event.

Protected Sub btnAdd_Click(ByVal sender as object, byVal e as system.EventArgs ) handles btnAdd.Click

   SqlDataSource.InsertParameters("CategoryID").DefaultValue = txtID.text
   SqlDataSource.InsertParameters("ShortName").DefaultValue = txtShortName.text
   ...
   ...
   ...
   Try
      SqlDataSource.Insert()
      txtID.test = ""
      txtShortName = ""
      ...
      ...
      ...
   Catch ex as Exception    
      lblError.text = "An exception ocurred. " & ex.Message
   End Try
End Sub


 

 
Maint