B
bgreer5050
I know I am missing something simple, but I am stuck. When I submit
the following for the employee info gets stored in scale1 and scale1
shows the employee number. Can someone show me my mistake. Thanks.
Code:
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub FormView1_ItemInserted1(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.FormViewInsertedEventArgs)
'Sub EmployeeFormView_ItemInserted(ByVal sender As Object,
ByVal e As FormViewInsertedEventArgs)
' Use the Exception property to determine whether an exception
' occurred during the insert operation.
If e.Exception Is Nothing Then
' Use the AffectedRows property to determine whether the
' record was inserted. Sometimes an error might occur
that
' does not raise an exception, but prevents the insert
' operation from completing.
If e.AffectedRows = 1 Then
'MsgBox("Data Recorded")
Response.Redirect("scrapredirect.aspx")
Else
MsgBox("WARNING --- DATA NOT RECORDED --- SERVER
ERROR")
' Use the KeepInInsertMode property to remain in
insert mode
' when an error occurs during the insert operation.
e.KeepInInsertMode = True
End If
Else
' Insert the code to handle the exception.
MsgBox("WARNING --- DATA NOT RECORDED --- SERVER ERROR")
' Use the ExceptionHandled property to indicate that the
' exception has already been handled.
e.ExceptionHandled = True
e.KeepInInsertMode = True
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Scrap Trailer</title>
</head>
<body bgcolor="#cccccc">
<form id="form1" runat="server">
<div style="text-align: left">
<asp:FormView ID="FormView1" runat="server" DataKeyNames="ID"
DataSourceID="AccessDataSource1"
DefaultMode="Insert" Style="z-index: 100; left: 28px;
position: absolute; top: 210px" Width="240px"
OnItemInserted="FormView1_ItemInserted1">
<EditItemTemplate>
ID:
<asp:Label ID="IDLabel1" runat="server" Text='<%#
Eval("ID") %>'></asp:Label><br />
Scale1:
<asp:TextBox ID="Scale1TextBox" runat="server" Text='<
%# Bind("Scale1") %>'>
</asp:TextBox><br />
Scale2:
<asp:TextBox ID="Scale2TextBox" runat="server" Text='<
%# Bind("Scale2") %>'>
</asp:TextBox><br />
Employee:
<asp:TextBox ID="EmployeeTextBox" runat="server"
Text='<%# Bind("Employee") %>'>
</asp:TextBox><br />
<asp:LinkButton ID="UpdateButton" runat="server"
CausesValidation="True" CommandName="Update"
Text="Update">
</asp:LinkButton>
<asp:LinkButton ID="UpdateCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel"
Text="Cancel">
</asp:LinkButton>
</EditItemTemplate>
<InsertItemTemplate>
Scale1:
<asp:TextBox ID="Scale1TextBox" runat="server" Text='<
%# Bind("Scale1") %>'>
</asp:TextBox><br />
Scale2:
<asp:TextBox ID="Scale2TextBox" runat="server" Text='<
%# Bind("Scale2") %>'>
</asp:TextBox><br />
Employee:
<asp:TextBox ID="EmployeeTextBox" runat="server"
Text='<%# Bind("Employee") %>'></asp:TextBox><br />
<br />
Date:
<asp:TextBox ID="DateTextBox" runat="server" Text='<%#
Bind("Date") %>' Visible="False"></asp:TextBox><br />
<br />
<asp:LinkButton ID="InsertButton" runat="server"
CausesValidation="True" CommandName="Insert"
Text="Record"></asp:LinkButton>
<br />
<br />
<asp:LinkButton ID="InsertCancelButton"
runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel">
</asp:LinkButton>
</InsertItemTemplate>
<ItemTemplate>
ID:
<asp:Label ID="IDLabel" runat="server" Text='<%#
Eval("ID") %>'></asp:Label><br />
Scale1:
<asp:Label ID="Scale1Label" runat="server" Text='<%#
Bind("Scale1") %>'></asp:Label><br />
Scale2:
<asp:Label ID="Scale2Label" runat="server" Text='<%#
Bind("Scale2") %>'></asp:Label><br />
Employee:
<asp:Label ID="EmployeeLabel" runat="server" Text='<%#
Bind("Employee") %>'></asp:Label><br />
<asp:LinkButton ID="EditButton" runat="server"
CausesValidation="False" CommandName="Edit"
Text="Edit">
</asp:LinkButton>
<asp:LinkButton ID="DeleteButton" runat="server"
CausesValidation="False" CommandName="Delete"
Text="Delete">
</asp:LinkButton>
<asp:LinkButton ID="NewButton" runat="server"
CausesValidation="False" CommandName="New"
Text="New">
</asp:LinkButton>
</ItemTemplate>
</asp:FormView>
<br />
<span style="font-size: 48pt">Scrap Data Entry </
span><asp:AccessDataSource ID="AccessDataSource1" runat="server"
ConflictDetection="CompareAllValues"
DataFile="~/App_Data/Spare_Parts_II_BCPC.mdb"
DeleteCommand="DELETE FROM [Scrap] WHERE [ID] = ? AND [Scale1] = ? AND
[Scale2] = ? AND [Employee] = ?"
InsertCommand="INSERT INTO [Scrap] ([Scale1], [Scale2],
[Employee],[Date]) VALUES (?, ?, ?,now())"
OldValuesParameterFormatString="original_{0}"
SelectCommand="SELECT * FROM [Scrap]"
UpdateCommand="UPDATE [Scrap] SET [Scale1] = ?, [Scale2]
= ?, [Employee] = ? WHERE [ID] = ? AND [Scale1] = ? AND [Scale2] = ?
AND [Employee] = ?">
<DeleteParameters>
<asparameter Name="original_Scale2" Type="Single" />
<asparameter Name="original_Scale1" Type="Single" />
<asparameter Name="original_Date" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asparameter Name="Employee" Type="String" />
<asparameter Name="Scale2" Type="Single" />
<asparameter Name="Scale1" Type="Single" />
<asparameter Name="Date" Type="String" />
<asparameter Name="original_Scale2" Type="Single" />
<asparameter Name="original_Scale1" Type="Single" />
<asparameter Name="original_Date" Type="String" />
</UpdateParameters>
<InsertParameters>
<asparameter Name="Employee" Type="String" />
<asparameter Name="Scale2" Type="Single" />
<asparameter Name="Scale1" Type="Single" />
<asparameter Name="Date" Type="DateTime" />
<asparameter Name="ID" Type="Int32" />
</InsertParameters>
</asp:AccessDataSource>
</div>
</form>
</body>
</html>
the following for the employee info gets stored in scale1 and scale1
shows the employee number. Can someone show me my mistake. Thanks.
Code:
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub FormView1_ItemInserted1(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.FormViewInsertedEventArgs)
'Sub EmployeeFormView_ItemInserted(ByVal sender As Object,
ByVal e As FormViewInsertedEventArgs)
' Use the Exception property to determine whether an exception
' occurred during the insert operation.
If e.Exception Is Nothing Then
' Use the AffectedRows property to determine whether the
' record was inserted. Sometimes an error might occur
that
' does not raise an exception, but prevents the insert
' operation from completing.
If e.AffectedRows = 1 Then
'MsgBox("Data Recorded")
Response.Redirect("scrapredirect.aspx")
Else
MsgBox("WARNING --- DATA NOT RECORDED --- SERVER
ERROR")
' Use the KeepInInsertMode property to remain in
insert mode
' when an error occurs during the insert operation.
e.KeepInInsertMode = True
End If
Else
' Insert the code to handle the exception.
MsgBox("WARNING --- DATA NOT RECORDED --- SERVER ERROR")
' Use the ExceptionHandled property to indicate that the
' exception has already been handled.
e.ExceptionHandled = True
e.KeepInInsertMode = True
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Scrap Trailer</title>
</head>
<body bgcolor="#cccccc">
<form id="form1" runat="server">
<div style="text-align: left">
<asp:FormView ID="FormView1" runat="server" DataKeyNames="ID"
DataSourceID="AccessDataSource1"
DefaultMode="Insert" Style="z-index: 100; left: 28px;
position: absolute; top: 210px" Width="240px"
OnItemInserted="FormView1_ItemInserted1">
<EditItemTemplate>
ID:
<asp:Label ID="IDLabel1" runat="server" Text='<%#
Eval("ID") %>'></asp:Label><br />
Scale1:
<asp:TextBox ID="Scale1TextBox" runat="server" Text='<
%# Bind("Scale1") %>'>
</asp:TextBox><br />
Scale2:
<asp:TextBox ID="Scale2TextBox" runat="server" Text='<
%# Bind("Scale2") %>'>
</asp:TextBox><br />
Employee:
<asp:TextBox ID="EmployeeTextBox" runat="server"
Text='<%# Bind("Employee") %>'>
</asp:TextBox><br />
<asp:LinkButton ID="UpdateButton" runat="server"
CausesValidation="True" CommandName="Update"
Text="Update">
</asp:LinkButton>
<asp:LinkButton ID="UpdateCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel"
Text="Cancel">
</asp:LinkButton>
</EditItemTemplate>
<InsertItemTemplate>
Scale1:
<asp:TextBox ID="Scale1TextBox" runat="server" Text='<
%# Bind("Scale1") %>'>
</asp:TextBox><br />
Scale2:
<asp:TextBox ID="Scale2TextBox" runat="server" Text='<
%# Bind("Scale2") %>'>
</asp:TextBox><br />
Employee:
<asp:TextBox ID="EmployeeTextBox" runat="server"
Text='<%# Bind("Employee") %>'></asp:TextBox><br />
<br />
Date:
<asp:TextBox ID="DateTextBox" runat="server" Text='<%#
Bind("Date") %>' Visible="False"></asp:TextBox><br />
<br />
<asp:LinkButton ID="InsertButton" runat="server"
CausesValidation="True" CommandName="Insert"
Text="Record"></asp:LinkButton>
<br />
<br />
<asp:LinkButton ID="InsertCancelButton"
runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel">
</asp:LinkButton>
</InsertItemTemplate>
<ItemTemplate>
ID:
<asp:Label ID="IDLabel" runat="server" Text='<%#
Eval("ID") %>'></asp:Label><br />
Scale1:
<asp:Label ID="Scale1Label" runat="server" Text='<%#
Bind("Scale1") %>'></asp:Label><br />
Scale2:
<asp:Label ID="Scale2Label" runat="server" Text='<%#
Bind("Scale2") %>'></asp:Label><br />
Employee:
<asp:Label ID="EmployeeLabel" runat="server" Text='<%#
Bind("Employee") %>'></asp:Label><br />
<asp:LinkButton ID="EditButton" runat="server"
CausesValidation="False" CommandName="Edit"
Text="Edit">
</asp:LinkButton>
<asp:LinkButton ID="DeleteButton" runat="server"
CausesValidation="False" CommandName="Delete"
Text="Delete">
</asp:LinkButton>
<asp:LinkButton ID="NewButton" runat="server"
CausesValidation="False" CommandName="New"
Text="New">
</asp:LinkButton>
</ItemTemplate>
</asp:FormView>
<br />
<span style="font-size: 48pt">Scrap Data Entry </
span><asp:AccessDataSource ID="AccessDataSource1" runat="server"
ConflictDetection="CompareAllValues"
DataFile="~/App_Data/Spare_Parts_II_BCPC.mdb"
DeleteCommand="DELETE FROM [Scrap] WHERE [ID] = ? AND [Scale1] = ? AND
[Scale2] = ? AND [Employee] = ?"
InsertCommand="INSERT INTO [Scrap] ([Scale1], [Scale2],
[Employee],[Date]) VALUES (?, ?, ?,now())"
OldValuesParameterFormatString="original_{0}"
SelectCommand="SELECT * FROM [Scrap]"
UpdateCommand="UPDATE [Scrap] SET [Scale1] = ?, [Scale2]
= ?, [Employee] = ? WHERE [ID] = ? AND [Scale1] = ? AND [Scale2] = ?
AND [Employee] = ?">
<DeleteParameters>
<asparameter Name="original_Scale2" Type="Single" />
<asparameter Name="original_Scale1" Type="Single" />
<asparameter Name="original_Date" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asparameter Name="Employee" Type="String" />
<asparameter Name="Scale2" Type="Single" />
<asparameter Name="Scale1" Type="Single" />
<asparameter Name="Date" Type="String" />
<asparameter Name="original_Scale2" Type="Single" />
<asparameter Name="original_Scale1" Type="Single" />
<asparameter Name="original_Date" Type="String" />
</UpdateParameters>
<InsertParameters>
<asparameter Name="Employee" Type="String" />
<asparameter Name="Scale2" Type="Single" />
<asparameter Name="Scale1" Type="Single" />
<asparameter Name="Date" Type="DateTime" />
<asparameter Name="ID" Type="Int32" />
</InsertParameters>
</asp:AccessDataSource>
</div>
</form>
</body>
</html>