การ update gridview แล้ว มันไม่เอาค่าใหม่มา update ครับ
นี้โค้ดผมครับ
Code (PHP)
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Edit.aspx.vb" Inherits="Epull_System_V3._0.Edit" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit.HTMLEditor"
TagPrefix="cc1" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Edit</title>
<style type="text/css">
.style1
{
width: 960px;
}
.style2
{
font-size: 40pt;
background-color: #CCFFFF;
}
.style3
{
height: 23px;
background-color: #99ffcc;
}
.style5
{
background-color: #99ffcc;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<center>
<table class="style1" style="background-color: ThreeDFace" cellpadding="0" cellspacing="0">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<tr>
<td colspan="10" align="center" width="100%" class="style2">
e-Pull System v3.0 Edit
</td>
</tr>
<tr>
<center>
<td colspan="10" style="border-style: solid; border-width: thin; background-color: white"
width="100%">
<asp:Panel ID="Panel1" runat="server" ScrollBars="Auto" Width="100%" Height="365px"
BorderColor="Black" BorderWidth="1px">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="GV_Index" EventName="RowDeleting" />
<asp:AsyncPostBackTrigger ControlID="GV_Index" EventName="RowEditing" />
<asp:AsyncPostBackTrigger ControlID="GV_Index" EventName="RowCancelingEdit" />
<asp:AsyncPostBackTrigger ControlID="GV_Index" EventName="RowUpdating" />
</Triggers>
<ContentTemplate>
<asp:GridView ID="GV_Index" runat="server" AutoGenerateColumns="False" CellPadding="4"
ForeColor="#333333" DataKeyNames="Part_id">
<RowStyle BackColor="#E3EAEB" />
<Columns>
<asp:TemplateField HeaderText="ID" ControlStyle-Width="90px" HeaderStyle-Font-Size="Larger">
<ItemTemplate>
<asp:Label ID="lblPart_id" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.Part_id") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtEditPart_id" size="5" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.Part_id") %>'></asp:TextBox>
</EditItemTemplate>
<ControlStyle Width="90px" />
<HeaderStyle Font-Size="Larger" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Part" ControlStyle-Width="90px" HeaderStyle-Font-Size="Larger">
<ItemTemplate>
<asp:Label ID="lblPart" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.Part_name") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtEditPart" size="5" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.Part_name") %>'></asp:TextBox>
</EditItemTemplate>
<ControlStyle Width="90px" />
<HeaderStyle Font-Size="Larger" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Product" ControlStyle-Width="90px" HeaderStyle-Font-Size="Larger">
<ItemTemplate>
<asp:Label ID="lblProduct" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.Product_name") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtEditProduct" size="5" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.Product_name") %>'></asp:TextBox>
</EditItemTemplate>
<ControlStyle Width="90px" />
<HeaderStyle Font-Size="Larger" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Dcm" ControlStyle-Width="90px" HeaderStyle-Font-Size="Larger">
<ItemTemplate>
<asp:Label ID="lblDcm" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.Dcm") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtEditDcm" size="5" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.Dcm") %>'></asp:TextBox>
</EditItemTemplate>
<ControlStyle Width="90px" />
<HeaderStyle Font-Size="Larger" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Status" ControlStyle-Width="90px" HeaderStyle-Font-Size="Larger">
<ItemTemplate>
<asp:Label ID="lblpart_status" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.part_status") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtEditpart_status" size="5" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.part_status") %>'></asp:TextBox>
</EditItemTemplate>
<ControlStyle Width="90px" />
<HeaderStyle Font-Size="Larger" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Eval" ControlStyle-Width="90px" HeaderStyle-Font-Size="Larger">
<ItemTemplate>
<asp:Label ID="lbleval" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.eval_name") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtEditeval" size="5" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.eval_name") %>'></asp:TextBox>
</EditItemTemplate>
<ControlStyle Width="90px" />
<HeaderStyle Font-Size="Larger" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Size" ControlStyle-Width="90px" HeaderStyle-Font-Size="Larger">
<ItemTemplate>
<asp:Label ID="lblsize" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.size") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtEditsize" size="5" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.size") %>'></asp:TextBox>
</EditItemTemplate>
<ControlStyle Width="90px" />
<HeaderStyle Font-Size="Larger" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Date" ControlStyle-Width="90px" HeaderStyle-Font-Size="Larger">
<ItemTemplate>
<asp:Label ID="lblpart_date" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.part_date") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtEditpart_date" size="5" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.part_date") %>'></asp:TextBox>
</EditItemTemplate>
<ControlStyle Width="90px" />
<HeaderStyle Font-Size="Larger" />
</asp:TemplateField>
<asp:CommandField ShowEditButton="True" CancelText="Cancel" DeleteText="Delete" EditText="Edit"
UpdateText="Update" HeaderText="Modify" />
<asp:CommandField ShowDeleteButton="True" HeaderText="Delete" />
</Columns>
<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#7C6F57" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
</td>
</center>
</tr>
<tr>
<td colspan="2" align="center" width="20%" class="style5">
Part
</td>
<td colspan="2" align="center" width="20%" class="style5">
Product
</td>
<td colspan="2" align="center" width="20%" class="style5">
DCM
</td>
<td colspan="2" align="center" width="20%" class="style5">
Part_Status
</td>
<td colspan="2" align="center" width="20%" class="style5">
Size
</td>
</tr>
<tr>
<td colspan="2" align="center" width="20%" class="style5">
<asp:TextBox ID="TB_Part" runat="server" Width="80%"></asp:TextBox>
</td>
<td colspan="2" align="center" width="20%" class="style5">
<asp:TextBox ID="TB_Product" runat="server" Width="80%"></asp:TextBox>
</td>
<td colspan="2" align="center" width="20%" class="style5">
<asp:TextBox ID="TB_DCM" runat="server"></asp:TextBox>
</td>
<td colspan="2" align="center" width="20%" class="style5">
<asp:TextBox ID="TB_Part_Status" runat="server"></asp:TextBox>
</td>
<td colspan="2" align="center" width="20%" class="style5">
<asp:TextBox ID="TB_Size" runat="server"></asp:TextBox>
</td>
</tr>
<tr height="5px">
<td class="style5">
</td>
<td class="style5">
</td>
<td class="style3">
</td>
<td class="style3">
</td>
<td class="style3">
</td>
<td class="style3">
</td>
<td class="style3">
</td>
<td class="style3">
</td>
<td class="style3">
</td>
<td class="style3">
</td>
</tr>
<tr>
<td class="style3">
</td>
<td class="style3">
</td>
<td class="style3">
</td>
<td class="style3">
</td>
<td class="style3">
</td>
<td class="style3">
</td>
<td class="style3">
</td>
<td class="style3">
</td>
<td class="style3">
<asp:ImageButton ID="IB_Search" runat="server" Height="50px" ImageUrl="~/e-Pull_v3/Images/search.png"
Width="50px" />
</td>
<td class="style3">
<asp:ImageButton ID="IB_Add" runat="server" Height="50px" ImageUrl="~/e-Pull_v3/Images/script-add.png" />
</td>
</tr>
<tr>
<td width="10%" class="style5" style="border-width: 0px">
</td>
<td width="10%" class="style5">
</td>
<td width="10%" class="style5">
</td>
<td width="10%" class="style5">
</td>
<td width="10%" class="style5">
</td>
<td width="10%" class="style5">
</td>
<td width="10%" class="style5">
</td>
<td width="10%" class="style5">
</td>
<td width="10%" class="style5">
Search
</td>
<td width="10%" class="style5">
Add
</td>
</tr>
<tr>
<td class="style5">
</td>
<td class="style5">
</td>
<td class="style5">
</td>
<td class="style5">
</td>
<td class="style5">
</td>
<td class="style5">
</td>
<td class="style5">
</td>
<td class="style5">
</td>
<td class="style5">
</td>
<td class="style5">
</td>
</tr>
</table>
</center>
</div>
</form>
</body>
</html>
Code (VB.NET)
Private Sub GV_Index_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GV_Index.RowUpdating
Dim part As TextBox = CType(GV_Index.Rows(e.RowIndex).FindControl("txtEditPart"), TextBox)
Dim product As TextBox = CType(GV_Index.Rows(e.RowIndex).FindControl("txtEditProduct"), TextBox)
Dim dcm As TextBox = CType(GV_Index.Rows(e.RowIndex).FindControl("txtEditDcm"), TextBox)
Dim part_status As TextBox = CType(GV_Index.Rows(e.RowIndex).FindControl("txtEditpart_status"), TextBox)
Dim eval As TextBox = CType(GV_Index.Rows(e.RowIndex).FindControl("txtEditProduct"), TextBox)
Dim size As TextBox = CType(GV_Index.Rows(e.RowIndex).FindControl("txtEditsize"), TextBox)
Dim part_date As TextBox = CType(GV_Index.Rows(e.RowIndex).FindControl("txtEditpart_date"), TextBox)
With dbm
.Table = "part"
.column.Add("part_name")
.column.Add("product_name")
.column.Add("dcm")
.column.Add("part_status")
.column.Add("size")
.column.Add("part_date")
.column.Add("eval_name")
.Values.Add(part.Text)
.Values.Add(product.Text)
.Values.Add(dcm.Text)
.Values.Add(part_status.Text)
.Values.Add(size.Text)
.Values.Add(part_date.Text)
.Values.Add(eval.Text)
.where = "data_id ='" + GV_Index.DataKeys.Item(e.RowIndex).Value.ToString() + "'"
End With
GV_Index.EditIndex = -1
show_index()
End Sub
เวลา update แล้วมันจำค่าเก่ามาupdate ครับ ไม่เอาค่าใหม่มา ช่วยทีครับTag : MySQL, VBScript, Web (ASP.NET), VB.NET
Date :
2011-01-07 01:29:37
By :
แม็ก
View :
1932
Reply :
11
Code (VB.NET)
Sub Page_Load(sender As Object, e As EventArgs)
Dim strConnString As String
strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& _
Server.MapPath("database/mydatabase.mdb")&";"
objConn = New OleDbConnection(strConnString)
objConn.Open()
IF Not Page.IsPostBack() Then
BindData()
End IF
End Sub
ตรง Page_Load() มีการเรียกซ้ำหรือเปล่าครับ ให้ดูตรง Page.IsPostBack() ด้วยครับ
Go to : ASP.NET GridView Control - RowCommand
Date :
2011-01-07 06:19:35
By :
webmaster
เด๋วลองเช็กดูก่อนครับ
ขอบคุณครับ mr.win
Date :
2011-01-10 16:14:48
By :
ผมเอง
ลองแล้วครับไม่ได้ครับ ตอน debug ดู ค่ามันก็เป็นค่าเก่าก่อนแก้ครับ
Code (PHP)
<center>
<table class="style1" style="background-color: ThreeDFace" cellpadding="0" cellspacing="0">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<tr>
<td colspan="10" align="center" width="100%" class="style2">
e-Pull System v3.0 Edit
</td>
</tr>
<tr>
<center>
<td colspan="10" style="border-style: solid; border-width: thin; background-color: white"
width="100%">
<asp:Panel ID="Panel1" runat="server" ScrollBars="Auto" Width="100%" Height="365px"
BorderColor="Black" BorderWidth="1px">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="GV_Index" EventName="RowDeleting" />
<asp:AsyncPostBackTrigger ControlID="GV_Index" EventName="RowEditing" />
<asp:AsyncPostBackTrigger ControlID="GV_Index" EventName="RowCancelingEdit" />
<asp:AsyncPostBackTrigger ControlID="GV_Index" EventName="RowUpdating" />
</Triggers>
<ContentTemplate>
<asp:GridView ID="GV_Index" runat="server" AutoGenerateColumns="False" CellPadding="4"
ForeColor="#333333" DataKeyNames="Part_id" OnRowEditing="GV_Index_RowEditing" OnRowCancelingEdit="GV_Index_RowCancelingEdit"
OnRowDeleting="GV_Index_RowDeleting" OnRowUpdating="GV_Index_RowUpdating">
<RowStyle BackColor="#E3EAEB" />
<Columns>
<asp:TemplateField HeaderText="ID" ControlStyle-Width="90px" HeaderStyle-Font-Size="Larger">
<ItemTemplate>
<asp:Label ID="lblPart_id" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.Part_id") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtEditPart_id" size="5" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.Part_id") %>'></asp:TextBox>
</EditItemTemplate>
<ControlStyle Width="90px" />
<HeaderStyle Font-Size="Larger" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Part" ControlStyle-Width="90px" HeaderStyle-Font-Size="Larger">
<ItemTemplate>
<asp:Label ID="lblPart" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.Part_name") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtEditPart" size="5" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.Part_name") %>'></asp:TextBox>
</EditItemTemplate>
<ControlStyle Width="90px" />
<HeaderStyle Font-Size="Larger" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Product" ControlStyle-Width="90px" HeaderStyle-Font-Size="Larger">
<ItemTemplate>
<asp:Label ID="lblProduct" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.Product_name") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtEditProduct" size="5" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.Product_name") %>'></asp:TextBox>
</EditItemTemplate>
<ControlStyle Width="90px" />
<HeaderStyle Font-Size="Larger" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Dcm" ControlStyle-Width="90px" HeaderStyle-Font-Size="Larger">
<ItemTemplate>
<asp:Label ID="lblDcm" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.Dcm") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtEditDcm" size="5" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.Dcm") %>'></asp:TextBox>
</EditItemTemplate>
<ControlStyle Width="90px" />
<HeaderStyle Font-Size="Larger" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Status" ControlStyle-Width="90px" HeaderStyle-Font-Size="Larger">
<ItemTemplate>
<asp:Label ID="lblpart_status" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.part_status") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtEditpart_status" size="5" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.part_status") %>'></asp:TextBox>
</EditItemTemplate>
<ControlStyle Width="90px" />
<HeaderStyle Font-Size="Larger" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Eval" ControlStyle-Width="90px" HeaderStyle-Font-Size="Larger">
<ItemTemplate>
<asp:Label ID="lbleval" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.eval_name") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtEditeval" size="5" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.eval_name") %>'></asp:TextBox>
</EditItemTemplate>
<ControlStyle Width="90px" />
<HeaderStyle Font-Size="Larger" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Size" ControlStyle-Width="90px" HeaderStyle-Font-Size="Larger">
<ItemTemplate>
<asp:Label ID="lblsize" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.size") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtEditsize" size="5" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.size") %>'></asp:TextBox>
</EditItemTemplate>
<ControlStyle Width="90px" />
<HeaderStyle Font-Size="Larger" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Date" ControlStyle-Width="90px" HeaderStyle-Font-Size="Larger">
<ItemTemplate>
<asp:Label ID="lblpart_date" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.part_date") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtEditpart_date" size="5" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.part_date") %>'></asp:TextBox>
</EditItemTemplate>
<ControlStyle Width="90px" />
<HeaderStyle Font-Size="Larger" />
</asp:TemplateField>
<asp:CommandField ShowEditButton="True" CancelText="Cancel" DeleteText="Delete" EditText="Edit"
UpdateText="Update" HeaderText="Modify" />
<asp:CommandField ShowDeleteButton="True" HeaderText="Delete" />
</Columns>
<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#7C6F57" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
</td>
</center>
Code (VB.NET)
Public Partial Class Edit
Inherits System.Web.UI.Page
Private dbm As New DatabaseManager()
Private Dt As New DataTable()
Private Gv As New GridView()
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack() Then
show_index()
End If
End Sub
Sub GV_Index_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GV_Index.RowCancelingEdit
GV_Index.EditIndex = -1
show_index()
End Sub
Sub GV_Index_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GV_Index.RowDeleting
dbm.delete("part", "part_id='" + GV_Index.DataKeys.Item(e.RowIndex).Value.ToString() + "'")
show_index()
End Sub
Sub GV_Index_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GV_Index.RowEditing
GV_Index.EditIndex = e.NewEditIndex
show_index()
End Sub
Sub GV_Index_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GV_Index.RowUpdating
Dim part As TextBox = CType(GV_Index.Rows(e.RowIndex).FindControl("txtEditPart"), TextBox)
Dim product As TextBox = CType(GV_Index.Rows(e.RowIndex).FindControl("txtEditProduct"), TextBox)
Dim dcm As TextBox = CType(GV_Index.Rows(e.RowIndex).FindControl("txtEditDcm"), TextBox)
Dim part_status As TextBox = CType(GV_Index.Rows(e.RowIndex).FindControl("txtEditpart_status"), TextBox)
Dim eval As TextBox = CType(GV_Index.Rows(e.RowIndex).FindControl("txtEditProduct"), TextBox)
Dim size As TextBox = CType(GV_Index.Rows(e.RowIndex).FindControl("txtEditsize"), TextBox)
Dim part_date As TextBox = CType(GV_Index.Rows(e.RowIndex).FindControl("txtEditpart_date"), TextBox)
With dbm
.Table = "part"
.column.Add("part_name")
.column.Add("product_name")
.column.Add("dcm")
.column.Add("part_status")
.column.Add("size")
.column.Add("part_date")
.column.Add("eval_name")
.Values.Add(part.Text)
.Values.Add(product.Text)
.Values.Add(dcm.Text)
.Values.Add(part_status.Text)
.Values.Add(size.Text)
.Values.Add(part_date.Text)
.Values.Add(eval.Text)
.where = "data_id ='" + GV_Index.DataKeys.Item(e.RowIndex).Value.ToString() + "'"
End With
GV_Index.EditIndex = -1
show_index()
End Sub
Public Sub show_index()
Dt = dbm.query("SELECT part_id,part_name,product_name,dcm,part_status,eval_name,size,part_date FROM part WHERE eval_name!='-' AND part_status='DELL' ORDER BY " + dbm.orderpart + ",product_name,part_status")
GV_Index.DataSource = Dt
GV_Index.DataBind()
hide()
End Sub
Public Sub hide()
Dim i As Integer = 0
GV_Index.HeaderRow.Cells(0).Visible = False
While (i <= GV_Index.Rows.Count - 1)
GV_Index.Rows(i).Cells(0).Visible = False
i = i + 1
End While
End Sub
Protected Sub IB_Add_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles IB_Add.Click
dbm.Add_New_Part(TB_Part.Text, TB_Product.Text, TB_DCM.Text, TB_Part_Status.Text, TB_Size.Text, "")
End Sub
End Class
ในฟ้งก์ชั่น GV_Index_RowUpdating ตอน debugก่อน update ค่าที่ได้มันเป็นค่าเก่าครับ ไม่ใช่ค่าที่แก้ไข
ช่วยทีคับ ติดมานานแล้ว
Date :
2011-01-11 22:46:23
By :
ผมเอง
ประมาณว่า ผม debug ดูค่าที่แก้ไข ก่อนที่จะทำการ update
debug แล้วค่าที่เห็นเป็นค่าเก่า ก่อนที่แก้ไขครับ
มันเลยเอาค่าเก่ามา update ให้ครับ
Date :
2011-01-12 08:40:32
By :
ผมเอง
คือมันน่าจะไปเรียกค่าเก่าตอนที่ Page_Load() ครับ ปัญหานี้ถือเป็นเรื่องที่พบเจอกันเป็นประจำครับ มีการแทรก Event ใน Page_Load() ครับ หรือไม่ลองดูตัวอย่างที่
Go to : ASP.NET Microsoft Access Edit/Update Record
Date :
2011-01-12 08:44:34
By :
webmaster
ขอบคุณ คุณmr.win ครับ ขอลองก่อนครับ
Date :
2011-01-12 14:35:05
By :
ผมเอง
ในหน้า pageload นั้นผมเอาคำสั่งออกทั้งหมดก็ยังเป็นเหมือนเดิมครับ
แนะนำทีครับ
Date :
2011-01-12 15:33:30
By :
ผมเอง
โอ้ววว ติด code นี้อยู่ตั้งนาน ใส่แค่คำว่า "EnableViewState="False" ก็ได้เลย ^_______^
ขอบคุณค่ะ
Date :
2011-10-04 17:02:27
By :
Thanks
Load balance : Server 03