

Public SqlConnection As New SqlConnection(connectionString) Public Shared connectionString As String = ConfigurationManager.AppSettings( "ConnectionString" ) 'Get the connectionstring from the webconfig and declare a global SqlConnection "SqlConnection" (new LiteralControl("Unable to insert Employee. Reason: " + ex.Message)) Update Query to insert into the database String City = (insertedItem.Controls as TextBox).Text String Address = (insertedItem.Controls as TextBox).Text String Title = (insertedItem.Controls as TextBox).Text String FirstName = (insertedItem.Controls as TextBox).Text String LastName = (insertedItem.Controls as TextBox).Text string EmployeeID = (insertedItem.Controls as TextBox).Text GridEditFormInsertItem insertedItem = (GridEditFormInsertItem)e.Item Get the GridEditFormInsertItem of the RadGrid Protected void RadGrid1_InsertCommand(object source, e) (new LiteralControl("Unable to update Employee. Reason: " + ex.Message)) String City = (editedItem.Controls as TextBox).Text String Address = (editedItem.Controls as TextBox).Text String Title = (editedItem.Controls as TextBox).Text String FirstName = (editedItem.Controls as TextBox).Text String LastName = (editedItem.Controls as TextBox).Text Access the textbox from the edit form template and store the values in string variables. GridEditableItem e editedItem = e.Item as GridEditableItem Get the GridEditableItem of the RadGrid Protected void RadGrid1_UpdateCommand(object source, e) (new LiteralControl("Unable to delete Employee. Reason: " + ex.Message)) String deleteQuery = "DELETE from Employees where EmployeeID='" + EmployeeID + "'" Get the primary key value using the DataKeyValue. GridDataItem item = (GridDataItem)e.Item Protected void RadGrid1_DeleteCommand(object source, e) SqlDataAdapter.SelectCommand = new SqlCommand(selectQuery, SqlConnection) String selectQuery = "SELECT * FROM Employees" Select Query to populate the RadGrid with data from table Employees.

Protected void RadGrid1_NeedDataSource(object source, e) Public SqlCommand SqlCommand = new SqlCommand() Public SqlDataAdapter SqlDataAdapter = new SqlDataAdapter() Declare a global SqlDataAdapter SqlDataAdapter Public SqlConnection SqlConnection = new SqlConnection(connectionString) Public static string connectionString = ConfigurationManager.

Get the connectionstring from the webconfig and declare a global SqlConnection "SqlConnection"
