473,473 Members | 2,134 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

ItemInserted Event Help

I tried to duplicate the code at msdn to create an ItemInserted event
on my form. Can someone tell me why it's not working. The code is as
follows:
<%@ 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">
Sub FormView1_ItemInserted(ByVal sender As Object, ByVal e As
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

Response.Redirect("partsrequest.aspx")

Else

Response.Redirect("wolf.aspx")

' 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.
Response.Redirect("search.aspx")

' 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>Untitled Page</title>
</head>
<body>
<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: 16; left: 28px;
position: absolute; top: 210px" Width="240px">
<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 />
<asp:LinkButton ID="InsertButton" runat="server"
CausesValidation="True" CommandName="Insert"
Text="Record"></asp:LinkButton>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;<br />
<br />
&nbsp;<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&nbsp;</
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]) VALUES (?, ?, ?)"
OldValuesParameterFormatString="original_{0}"
SelectCommand="SELECT * FROM [Scrap]"
UpdateCommand="UPDATE [Scrap] SET [Scale1] = ?, [Scale2]
= ?, [Employee] = ? WHERE [ID] = ? AND [Scale1] = ? AND [Scale2] = ?
AND [Employee] = ?">
<DeleteParameters>
<asp:Parameter Name="original_ID" Type="Int32" />
<asp:Parameter Name="original_Scale1" Type="Single" />
<asp:Parameter Name="original_Scale2" Type="Single" />
<asp:Parameter Name="original_Employee" Type="String" /
>
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Scale1" Type="Single" />
<asp:Parameter Name="Scale2" Type="Single" />
<asp:Parameter Name="Employee" Type="String" />
<asp:Parameter Name="original_ID" Type="Int32" />
<asp:Parameter Name="original_Scale1" Type="Single" />
<asp:Parameter Name="original_Scale2" Type="Single" />
<asp:Parameter Name="original_Employee" Type="String" /
>
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="Scale1" Type="Single" />
<asp:Parameter Name="Scale2" Type="Single" />
<asp:Parameter Name="Employee" Type="String" />
</InsertParameters>
</asp:AccessDataSource>

</div>
</form>
</body>
</html>
Jun 27 '08 #1
0 1187

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code...
6
by: rich_poppleton | last post by:
Help.... I've got a textarea where people type in a description. However for certain reasons we need to stop them typing !$*^ . I have a solution this which works fine in IE: function...
4
by: Corepaul | last post by:
I am a newbie using Access 2000. I am using the following test in the txtAlbum OnExit procedure to prevent leaving an empty text box for a required field If (IsNull(txtAlbum.Value)) Or...
3
by: Melissa | last post by:
What specifically causes the Format event of a report's section to fire? Thanks! Melissa
3
by: Steve Long | last post by:
Hello, I have a VB.NET class that raises a MapSet event that passes an argument of type interop.MapObjects2.MapClass. I have a C# class that inherits from this VB.NET class. How can I handle the...
13
by: Charles Law | last post by:
Mr "yEaH rIgHt" posted the following link about a week ago in answer to my question about removing event handlers. > http://www.vbinfozine.com/t_bindevt.shtml Following on from that post, the...
9
by: jeff | last post by:
New VB user...developer... Situation...simplified... - I want to wrap a pre and post event around a system generated where the pre-event will always execute before the system event and the...
9
by: AG | last post by:
Using VS 2005. Usually I work in VB.NET. In code behind when I need to add code to an event, I just select the object in the upper left dropdown of the code window and then the desired event in...
6
by: blaine | last post by:
Hello, I'm currently overriding function keys (F1 to F4) to perform other actions. In order to do this the default popup windows of Help (F1), Seach(F3) etc must be turned off. In FF it's easy...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.