Using Database Forms View For User Input

B

bgreer5050

I have a web page that I use to collect requests from users. Instead
of a form, I use a database connection with a forms view in the insert
mode as the default. I would like to send some of the data in an
email as well as the database upon the user clicking "insert record".

I thought something like this would work:

mm.Subject =<%("Mfr")%>

or

mm.subject = <%# Bind("Mfr") %>



Mfr being one of the fields my user enters data into.

Can someone help me with the correct way?




Here is the complete 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_PageIndexChanging(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.FormViewPageEventArgs)
Const ToAddress As String = "(e-mail address removed)"
Dim mm As New Net.Mail.MailMessage("(e-mail address removed)", ToAddress)
mm.Subject = "Mfr"
mm.Body = "Body"
mm.IsBodyHtml = False
Dim smtp As New Net.Mail.SmtpClient
smtp.Send(mm)
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:AccessDataSource ID="DataSourceRequestParts"
runat="server" ConflictDetection="CompareAllValues"
DataFile="~/App_Data/Spare_Parts_II_BCPC.mdb"
DeleteCommand="DELETE FROM [Inventory] WHERE [ID1] = ? AND [Order] = ?
AND [Mfr] = ? AND [MFR_PART#] = ? AND [Description] = ? AND
[Application] = ?"
InsertCommand="INSERT INTO [Inventory] ([Order], [Mfr],
[MFR_PART#], [Description], [Application]) VALUES (?, ?, ?, ?, ?)"
OldValuesParameterFormatString="original_{0}"
SelectCommand="SELECT [Order], [Mfr], [MFR_PART#] AS column1,
[Description], [Application], [ID1] FROM [Inventory]"
UpdateCommand="UPDATE [Inventory] SET [Order] = ?, [Mfr]
= ?, [MFR_PART#] = ?, [Description] = ?, [Application] = ? WHERE [ID1]
= ? AND [Order] = ? AND [Mfr] = ? AND [MFR_PART#] = ? AND
[Description] = ? AND [Application] = ?">
<DeleteParameters>
<asp:parameter Name="original_ID1" Type="Int32" />
<asp:parameter Name="original_Order" Type="String" />
<asp:parameter Name="original_Description"
Type="String" />
<asp:parameter Name="original_Application"
Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:parameter Name="Order" Type="String" />
<asp:parameter Name="Mfr" Type="String" />
<asp:parameter Name="column1" Type="String" />
<asp:parameter Name="Description" Type="String" />
<asp:parameter Name="Application" Type="String" />
<asp:parameter Name="original_ID1" Type="Int32" />
<asp:parameter Name="original_Order" Type="String" />
<asp:parameter Name="original_Description"
Type="String" />
<asp:parameter Name="original_Application"
Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:parameter Name="Order" Type="String" />
<asp:parameter Name="Mfr" Type="String" />
<asp:parameter Name="column1" Type="String" />
<asp:parameter Name="Description" Type="String" />
<asp:parameter Name="Application" Type="String" />
<asp:parameter Name="ID1" Type="Int32" />
</InsertParameters>
</asp:AccessDataSource>
&nbsp;
<asp:FormView ID="FormView1" runat="server" DataKeyNames="ID1"
DataSourceID="DataSourceRequestParts"
DefaultMode="Insert" Height="328px" Style="position:
relative" Width="348px"
OnPageIndexChanging="FormView1_PageIndexChanging">
<EditItemTemplate>
Order:
<asp:TextBox ID="OrderTextBox" runat="server" Text='<
%# Bind("Order") %>'>
</asp:TextBox><br />
Mfr:
<asp:TextBox ID="MfrTextBox" runat="server" Text='<%#
Bind("Mfr") %>'>
</asp:TextBox><br />
column1:
<asp:TextBox ID="column1TextBox" runat="server" Text='<
%# Bind("column1") %>'>
</asp:TextBox><br />
Description:
<asp:TextBox ID="DescriptionTextBox" runat="server"
Text='<%# Bind("Description") %>'>
</asp:TextBox><br />
Application:
<asp:TextBox ID="ApplicationTextBox" runat="server"
Text='<%# Bind("Application") %>'>
</asp:TextBox><br />
ID1:
<asp:Label ID="ID1Label1" runat="server" Text='<%#
Eval("ID1") %>'></asp:Label><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>
Order: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp;<asp:TextBox ID="OrderTextBox"
runat="server" Text='<%# Bind("Order") %>'></
asp:TextBox><br />
<br />
Mfr: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;&nbsp; &nbsp;<asp:TextBox
ID="MfrTextBox" runat="server" Text='<%#
Bind("Mfr") %>'></asp:TextBox><br />
<br />
column1: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;<asp:TextBox ID="column1TextBox"
runat="server" Text='<%# Bind("column1") %>'></
asp:TextBox><br />
<br />
Description: &nbsp; &nbsp; &nbsp;
<asp:TextBox ID="DescriptionTextBox" runat="server"
Text='<%# Bind("Description") %>'></asp:TextBox><br />
<br />
Application: &nbsp; &nbsp;&nbsp; &nbsp;<asp:TextBox
ID="ApplicationTextBox" runat="server"
Text='<%# Bind("Application") %>'></
asp:TextBox><br />
&nbsp;
<asp:LinkButton ID="InsertCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel"
Style="left: 233px; position: absolute; top:
301px" Text="Cancel"></asp:LinkButton>
<asp:LinkButton ID="InsertButton" runat="server"
CausesValidation="True" CommandName="Insert"
PostBackUrl="~/redirect.aspx" Style="left: 98px;
position: relative; top: 55px"
Text="Insert"></asp:LinkButton>
</InsertItemTemplate>
<ItemTemplate>
Order:
<asp:Label ID="OrderLabel" runat="server" Text='<%#
Bind("Order") %>'></asp:Label><br />
Mfr:
<asp:Label ID="MfrLabel" runat="server" Text='<%#
Bind("Mfr") %>'></asp:Label><br />
column1:
<asp:Label ID="column1Label" runat="server" Text='<%#
Bind("column1") %>'></asp:Label><br />
Description:
<asp:Label ID="DescriptionLabel" runat="server" Text='<
%# Bind("Description") %>'></asp:Label><br />
Application:
<asp:Label ID="ApplicationLabel" runat="server" Text='<
%# Bind("Application") %>'></asp:Label><br />
ID1:
<asp:Label ID="ID1Label" runat="server" Text='<%#
Eval("ID1") %>'></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>

</div>
</form>
</body>
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top