asp.net实例代码之DataGrid数据编辑
本文导语: asp.net datagrid控件的例子,演示了datagrid控件中数据编辑的方法。 代码: 代码示例: Sub Page_Load(Sender As Object, E As EventArgs) Dim strConnection As String Dim strSQL As String Dim objDataSet As New DataSet() ...
asp.net datagrid控件的例子,演示了datagrid控件中数据编辑的方法。
代码:
Sub Page_Load(Sender As Object, E As EventArgs)
Dim strConnection As String
Dim strSQL As String
Dim objDataSet As New DataSet()
Dim objConnection As OleDbConnection
Dim objAdapter As OleDbDataAdapter
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=C:Northwind.mdb"
strSQL = "SELECT FirstName, LastName FROM Employees;"
objConnection = New OledbConnection(strConnection)
objAdapter = New OledbDataAdapter(strSQL, objConnection)
objAdapter.Fill(objDataSet, "Employees")
dgNameList1.DataSource = objDataSet.Tables("Employees").DefaultView
dgNameList1.DataBind()
End Sub
在datagrid控件中编辑数据
Original Data
Data with new Row
Data with edited Row
Data with deleted Row