<%@ Import Namespace="System.Data.SqlClient" %>
<Script Runat="Server">
Sub Page_Load
If Not IsPostBack Then
BindDataGrid
End If
End Sub
Sub BindDataGrid
Dim conNorthwind As SqlConnection
Dim cmdSelect As SqlCommand
conNorthwind=New SqlConnection( "Server=localhost; UID=sa;PWD= secret;Database=Northwind" )
cmdSelect = New SqlCommand( "Select * From Employees", conNorthwind )
conNorthwind.Open()
dgrdEmployees.DataSource = cmdSelect.ExecuteReader()
dgrdEmployees.DataBind()
conNorthwind.Close()
End Sub
Sub dgrdEmployeesEditCommand( s As Object, e As DataGridCommandEventArgs )
dgrdEmployees.EditItemIndex = e.Item.ItemIndex
BindDataGrid
End Sub
</Script>
<html>
<head><title>ExpertDataGridEditCommandColumn.aspx</title></head>
<body>
<form Runat="Server">
<asp:DataGrid
ID="dgrdEmployees"
OnEditCommand="dgrdEmployeesEditCommand"
AutoGenerateColumns="False"
CellPadding="11"
Runat="Server">
<Columns>
<asp:BoundColumn
HeaderText="Designation Of Employees"
DataField="Title" />
<asp:EditCommandColumn
EditText="Edit!"
UpdateText="Update!"
CancelText="Cancel!" />
</Columns>
</asp:DataGrid>
</form>
</body>
</html> |