hello :)
I just want to ask a favor regarding the code on how to Update the edited data from the gridview. thanks.
here's the code.
<%@ Page Language="VB"%> <%--AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default"--%>
<%@ Import Namespace="System.Data.Oledb" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Private Sub Page_Load()
Dim connection As OleDbConnection
connection = New OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source=C:\Users\emong\Documents\Visual Studio 2008\WebSite3\App_Data/dbLupon.mdb")
connection.Open()
Dim command As OleDbCommand
command = New OleDbCommand("Select * from tblLupon_C", connection)
Dim DataReader As OleDbDataReader
DataReader = command.ExecuteReader()
GridView1.DataSource = DataReader
GridView1.DataBind()
connection.Close()
End Sub
Protected Sub GridView1_RowEditing(ByVal sender As Object, ByVal e As GridViewEditEventArgs)
GridView1.EditIndex = e.NewEditIndex
Call Page_Load()
End Sub
Protected Sub Gridview1_RowUpdating(ByVal sender As Object, ByVal e As GridViewUpdatedEventArgs)
Dim connection As OleDbConnection
connection = New OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source=C:\Users\emong\Documents\Visual Studio 2008\WebSite3\App_Data/dbLupon.mdb")
connection.Open()
Dim command As OleDbCommand
command = New OleDbCommand("UPDATE tblLUPON_C SET REGION_C = '& GridView1.Item(0, GridView1.CurrentRow.Index).[Value] &', PROVINCE_C = '& GridView1.Item(1, GridView1.CurrentRow.Index).[Value] &', CITYMUN_C = '& GridView1.Item(2, GridView1.CurrentRow.Index).[Value] &', BARANGAY_C = '& GridView1.Item(3, GridView1.CurrentRow.Index).[Value] &', LAST_M = '& GridView1.Item(4, GridView1.CurrentRow.Index).[Value] &', FIRST_M = '& GridView1.Item(5, GridView1.CurrentRow.Index).[Value] &', MIDDLE_M = '& GridView1.Item(6, GridView1.CurrentRow.Index).[Value] &', SUFFIX_M = '& GridView1.Item(7, GridView1.CurrentRow.Index).[Value] &', POSITION_C = '& GridView1.Item(8, GridView1.CurrentRow.Index).[Value] &', SEX_C = '& GridView1.Item(9, GridView1.CurrentRow.Index).[Value] &'", connection)
Dim DataReader As OleDbDataReader
DataReader = command.ExecuteReader()
GridView1.DataSource = DataReader
GridView1.DataBind()
connection.Close()
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:GridView ID="GridView1" runat="server" EmptyDataText="No record found"
AutoGenerateEditButton="True"
OnRowUpdating="Gridview1_RowUpdating"
OnRowEditing= "GridView1_RowEditing">
</asp:GridView>
</div>
</form>
</body>
</html>
The Gridview1_RowUpdating was the error.
your help will be highly appreciated :D
thank you. thank you.