asp:DataGrid with data edit : DataGrid Edit « ADO.net Database « ASP.Net






asp:DataGrid with data edit

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>

<script language="VB" runat="server">
  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

</script>

<html>
 <body>
  <table width="100%">
   <tr>
    <td>Original Data</td>
    <td>Data with new Row</td>
    <td>Data with edited Row</td>
    <td>Data with deleted Row</td>
   </tr>
   <tr>
    <td valign="top"><asp:DataGrid id="dgNameList1" runat="server" /></td>
    <td valign="top"><asp:DataGrid id="dgNameList2" runat="server" /></td>
    <td valign="top"><asp:DataGrid id="dgNameList3" runat="server" /></td>
    <td valign="top"><asp:DataGrid id="dgNameList4" runat="server" /></td>
   </tr>
  </table>
 </body>
</html>

           
       








Related examples in the same category

1.Add asp:textbox to asp:datagrid edit mode
2.Use asp:datagrid to add, update
3.Edit data in asp:datagrid