472,958 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

I want to send in the email, the content of formview control

Hi Everyone,

I'm deen from Riyadh.

Please do help me with some problem i have. I have this formview
control setup to recieved inputs from user (textbox, dropdownlist,
others).

After inserting, I want to send the data via email, the problem is how
do I do that?

Simple form.request dont work, somebody told me to use findcontrol,
please explain.

I am new to asp.net but i quiet like it.

Thank you very much.

Deen

Jan 11 '07 #1
3 4458
Thank you very much Nat,

But you see i have been through that site a thousand times. In that
example in 4guysfromrolla, they were using simple form But what I have
is Formview control and I dont know how to use findcontrol to add the
data inputted in the email that i will be sending.

With simple form easy but formview im getting blank values in the sent
email..

eg : findcontrol.formview.textbox1 and assign it into a value..
thanks everyone..
Nate wrote:
Deen,

Google is your friend.

Rather than me copy-n-paste code from one of my projects and explain it,
here is a 4guysfromrolla link (haven't read it, but I'm sure it has some
useful info in it):

http://aspnet.4guysfromrolla.com/articles/072606-1.aspx

"YMPN" wrote:
Hi Everyone,

I'm deen from Riyadh.

Please do help me with some problem i have. I have this formview
control setup to recieved inputs from user (textbox, dropdownlist,
others).

After inserting, I want to send the data via email, the problem is how
do I do that?

Simple form.request dont work, somebody told me to use findcontrol,
please explain.

I am new to asp.net but i quiet like it.

Thank you very much.

Deen
Jan 12 '07 #2
bpd
Show us the code.
YMPN wrote:
Thank you very much Nat,

But you see i have been through that site a thousand times. In that
example in 4guysfromrolla, they were using simple form But what I have
is Formview control and I dont know how to use findcontrol to add the
data inputted in the email that i will be sending.

With simple form easy but formview im getting blank values in the sent
email..

eg : findcontrol.formview.textbox1 and assign it into a value..
thanks everyone..
Nate wrote:
Deen,

Google is your friend.

Rather than me copy-n-paste code from one of my projects and explain it,
here is a 4guysfromrolla link (haven't read it, but I'm sure it has some
useful info in it):

http://aspnet.4guysfromrolla.com/articles/072606-1.aspx

"YMPN" wrote:
Hi Everyone,
>
I'm deen from Riyadh.
>
Please do help me with some problem i have. I have this formview
control setup to recieved inputs from user (textbox, dropdownlist,
others).
>
After inserting, I want to send the data via email, the problem is how
do I do that?
>
Simple form.request dont work, somebody told me to use findcontrol,
please explain.
>
I am new to asp.net but i quiet like it.
>
Thank you very much.
>
Deen
>
>
Jan 12 '07 #3
My issue I think is simple but since i'm coming from a CFM background I
have some difficulty. But ASP.Net has given me new excitement in my web
development life..
Here is the formview where the data is collected.....

-----------------------------------------------------------

<asp:FormView ID="FormView1" runat="server"
DataSourceID="DataSourceForm" DefaultMode="Insert"
Width="100%">
<InsertItemTemplate>
<table>
<tr>
<td rowspan="2" style="width: 350px">
</td>
<td colspan="2" rowspan="2">
<strong><span style="color: #56b63b"><span
style="color: #0000ff"></span>Please Enter
Required Information<span style="color:
blue"</span></span></strong>
</td>
</tr>
<%-- user name set visible = false ??? --%>
<tr>
<td style="width: 400px; height: 33px;">
<asp:DropDownList ID="UserName" runat="server"
DataSourceID="SqlDataSource6" DataTextField="UserName"
DataValueField="UserName"
SelectedValue='<%# Bind("UserName") %>' Visible="False"
AutoPostBack="True">
</asp:DropDownList><asp:SqlDataSource
ID="SqlDataSource6" runat="server" ConnectionString="<%$
ConnectionStrings:RoomReservationConnectionString %>"
SelectCommand="SELECT [Fullname], [Id],
[UserName] FROM [UserInfo] WHERE ([UserName] = @UserName)">
<SelectParameters>
<asp:QueryStringParameter
DefaultValue="1" Name="UserName" QueryStringField="UserName"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<br />
</tr>
<tr>
<td style="width: 350px; height: 27px">
</td>
<td style="width: 800px; height: 27px">
Type of Reservation</td>
<td style="width: 400px; height: 27px">
<br />
<asp:DropDownList ID="DropDownList"
runat="server" SelectedValue='<%# Bind("Reservation_cat") %>'
DataSourceID="SqlDataSource1"
DataTextField="category" DataValueField="category"
AppendDataBoundItems="True"
AutoPostBack="True" OnTextChanged="DropDownList_TextChanged">
</asp:DropDownList><asp:SqlDataSource
ID="SqlDataSource1" runat="server" ConnectionString="<%$
ConnectionStrings:RoomReservationConnectionString %>"
SelectCommand="SELECT * FROM
[reservation_category] ORDER BY [cat_id] ASC"></asp:SqlDataSource>
<br />
<br />
</td>
</tr>
<tr>
<td style="width: 350px; height: 27px;">
</td>
<td style="width: 800px; height: 27px;">
Date From</td>
<td style="width: 400px; height: 27px;">
<ew:CalendarPopup ID="CalendarPopup1"
runat="server" PostedDate="" SelectedDate='<%# Bind("Date_From") %>'
ImageUrl="~/images/calendar4.jpg"
ControlDisplay="TextBoxImage" UpperBoundDate="12/31/9999 23:59:59"
Culture="(Default)" Text="Select Date
From">
<ButtonStyle Font-Names="verdana"
Font-Size="8pt" BackColor="#DEE37F" />
</ew:CalendarPopup>
<br />
<br />
</td>
</tr>
<tr>
<td style="width: 350px">
</td>
<td style="width: 800px">
Date To</td>
<td style="width: 400px">
<ew:CalendarPopup ID="CalendarPopup2"
ImageUrl="~/images/calendar4.jpg" ControlDisplay="TextBoxImage"
runat="server" SelectedDate='<%#
Bind("Date_To") %>' Text="Select Date To">
<ButtonStyle BackColor="#DEE37F"
Font-Names="verdana" Font-Size="8pt" />
</ew:CalendarPopup>
<br />
<br />
</td>
</tr>
<tr>
<td style="width: 350px">
</td>
<td style="width: 800px">
Time From</td>
<td style="width: 400px">
<ew:TimePicker ID="tpDemo2" runat="server"
ImageUrl="~/images/calendar3.jpg" NumberOfColumns="3"
LowerBoundTime="11/25/3506 07:00:00"
UpperBoundTime="11/25/3506 23:00:00" ControlDisplay="TextBoxImage"
PopupLocation="Bottom" PopupWidth="170px"
PopupHeight="178px" SelectedValue='<%# Bind("Time_From", "{0:t}") %>'
PostedTime="7:00 PM"
SelectedTime="11/25/3506 19:00:28" Text="Select Time Start">
<SelectedTimeStyle BackColor="Khaki"
ForeColor="Black" />
<TimeStyle BackColor="SteelBlue"
ForeColor="White" />
<ButtonStyle BackColor="#DEE37F"
Font-Names="verdana" Font-Size="8pt" />
</ew:TimePicker>
<br />
<br />
</td>
</tr>
<tr>
<td style="width: 350px">
</td>
<td style="width: 800px">
Time To</td>
<td style="width: 400px">
<ew:TimePicker ID="TimePicker1" runat="server"
ImageUrl="~/images/calendar3.jpg"
ControlDisplay="TextBoxImage"
NumberOfColumns="3" LowerBoundTime="11/25/3506 07:00:00"
UpperBoundTime="11/25/3506 23:00:00"
PopupLocation="Bottom" PopupWidth="170px"
PopupHeight="178px" SelectedValue='<%#
Bind("Time_To", "{0:t}") %>' PostedTime="7:00 PM"
SelectedTime="11/25/3506 19:00:28"
Text="Select Time Ends">
<SelectedTimeStyle BackColor="Khaki"
ForeColor="Black" />
<TimeStyle BackColor="SteelBlue"
ForeColor="White" />
<ButtonStyle BackColor="#DEE37F"
Font-Names="verdana" Font-Size="8pt" />
</ew:TimePicker>
<br />
<br />
</td>
</tr>
<tr>
<td style="width: 350px">
</td>
<td style="width: 800px" valign="top">
Activity</td>
<td style="width: 400px">
<span style="color: red"><strong>Events or
Reasons for this Reservation</strong></span><br />
<asp:TextBox ID="ReasonTextBox" runat="server"
Text='<%# Bind("Reason") %>' CausesValidation="True"
Height="50px" TextMode="MultiLine"
Width="250px"></asp:TextBox>
<asp:RequiredFieldValidator
ID="RequiredFieldValidator1" runat="server"
ControlToValidate="ReasonTextBox"
ErrorMessage="This Field is
Required"></asp:RequiredFieldValidator>
<br />
</td>
</tr>
<%-- Start of room--%>
<tr>
<td style="width: 350px" valign="top">
</td>
<td style="width: 800px" valign="top">
<br />
Room No.</td>
<td style="width: 400px" valign="top">
<br />
<asp:DropDownList ID="RoomNo" runat="server"
DataSourceID="SqlDataSource3" DataTextField="RoomNo"
AppendDataBoundItems="true"
DataValueField="RoomNo" SelectedValue='<%# Bind("RoomNo") %>'>
<asp:ListItem Selected="True">Pls. Select
Your Room No.</asp:ListItem>
</asp:DropDownList><br />
<br />
</td>
</tr>
<tr>
<td style="width: 350px">
</td>
<td style="width: 800px" valign="top">
<br />
Equipment</td>
<td style="width: 400px">
<asp:DropDownList ID="DropDownList1"
runat="server" DataSourceID="SqlDataSource5"
DataTextField="EquipmentName"
DataValueField="EquipmentName" SelectedValue='<%# Bind("Equipments")
%>'
AppendDataBoundItems="true">
<asp:ListItem Selected="True">Pls. Select
Your Equipment</asp:ListItem>
</asp:DropDownList><br />
<br />
</td>
</tr>
<%-- extra location for equipment reservation--%>
<tr id="locatione" runat="server" visible="false">
<td style="width: 350px">
</td>
<td style="width: 800px" valign="top">
<br />
Location for Equipment</td>
<td style="width: 400px">
<br />
<asp:TextBox ID="TextBox1" runat="server"
CausesValidation="True" Text='<%# Bind("OtherRoomNo") %>'
Width="250px"></asp:TextBox><br />
<br />
</td>
</tr>
<%-- extra location for equipment reservation--%>
<asp:SqlDataSource ID="SqlDataSource3" runat="server"
ConnectionString="<%$ ConnectionStrings:RoomReservationConnectionString
%>"
SelectCommand="SELECT * FROM
[RoomInfo]"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource5" runat="server"
ConnectionString="<%$ ConnectionStrings:RoomReservationConnectionString
%>"
SelectCommand="SELECT * FROM
[Equipments]"></asp:SqlDataSource>
<%--insert/cancel button--%>
<tr>
<td style="width: 350px">
</td>
<td colspan="3" valign="top">
<asp:ImageButton ID="InsertButton"
runat="server" ForeColor="#56b63b" CommandName="Insert"
ImageUrl="~/images/insert_all.jpg"
OnClientClick="return confirm('Are you certain that you want to reserve
this details?');">
</asp:ImageButton>
<asp:ImageButton ID="InsertCancelButton"
runat="server" ForeColor="#56b63b" CausesValidation="False"
CommandName="Cancel"
ImageUrl="~/images/cancel_all.jpg" OnClientClick="return confirm('Are
you certain that you want to cancel this details?');">
</asp:ImageButton>
</td>
</tr>
<%--insert/cancel button--%>
</table>
</InsertItemTemplate>
</asp:FormView>
And here the code that sends the email....


Protected Sub FormView1_ItemInserted(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.FormViewInsertedEventArg s) Handles
FormView1.ItemInserted
' ''***** Send Email ******************
''Find controls value on page and send to email ??? -
HOW??????

Dim strBody As String
Dim strMailTo As String

strMailTo = Session("UserName").ToString & "@kfmc.med.sa"
strBody = "Dear " & Session("FullName").ToString &
"<br><br>Thank you for using Room & Equipment Reservation System, Your
reservation has been received <br><br>"
' strBody = strBody & "<brV>To view the details of your
reservation online, <a
href=http://rkweb01:8779/viewmyreserved_admin.aspxClick Here!</a>"
strBody = strBody & "<br><br>Best Regards, <br>"
strBody = strBody & "<br>Administrator <br>"
strBody = strBody & "<br><br>Ext: 2174, 2529"
strBody = strBody & "<br><br>Ext:
RoomReservation@(kfmc.med.sa)"

Dim msg As System.Net.Mail.MailMessage = New
System.Net.Mail.MailMessage
Dim strFrom As System.Net.Mail.MailAddress = New
System.Net.Mail.MailAddress("xxxxxx")
msg.Subject = "New Room Reservation"
msg.To.Add(strMailTo)
msg.CC.Add("xxxxxx")
msg.From = strFrom
msg.IsBodyHtml = True
msg.Body = strBody

Try
Dim smtp As System.Net.Mail.SmtpClient = New
System.Net.Mail.SmtpClient
smtp.Host = "xxxxxxxx"
smtp.Send(msg)
'***** End of Sending Email ***************
' strRN = ""
Response.Redirect("viewmyreserved_admin.aspx")
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub

On Jan 12, 11:56 pm, "bpd" <bryan.da...@rollcoater.comwrote:
Show us the code.

YMPN wrote:
Thank you very much Nat,
But you see i have been through that site a thousand times. In that
example in 4guysfromrolla, they were using simple form But what I have
is Formview control and I dont know how to use findcontrol to add the
data inputted in the email that i will be sending.
With simple form easy but formview im getting blank values in the sent
email..
eg : findcontrol.formview.textbox1 and assign it into a value..
thanks everyone..
Nate wrote:
Deen,
Google is your friend.
Rather than me copy-n-paste code from one of my projects and explain it,
here is a 4guysfromrolla link (haven't read it, but I'm sure it has some
useful info in it):
>http://aspnet.4guysfromrolla.com/articles/072606-1.aspx
"YMPN" wrote:
Hi Everyone,
I'm deen from Riyadh.
Please do help me with some problem i have. I have this formview
control setup to recieved inputs from user (textbox, dropdownlist,
others).
After inserting, I want to send the data via email, the problem is how
do I do that?
Simple form.request dont work, somebody told me to use findcontrol,
please explain.
I am new to asp.net but i quiet like it.
Thank you very much.
Deen
Jan 13 '07 #4

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

Similar topics

0
by: aboomar10 | last post by:
this work is done under ASP.NET2 error when adding a "FormView" control to a "content" control the "content" control is in a aspx page that is added to a masterPage -- aboomar10
6
by: Douglas J. Badin | last post by:
Earlier this month, there was a posting about this without a definitive answer. If you place a Wizard inside a FormView's EditItemTemplate the bound fields contained within the View will display...
2
by: P. Yanzick | last post by:
Hello, I am creating an edit template for a FormView control, changing one of the textboxes to a dropdown box. The dropdown will be populated from a simple table with the primary key, and a...
7
by: Lorenzino | last post by:
Hi, I have a problem with bindings in a formview. I have a formview; in the insert template i've created a wizard control and inside it i have an HTML table with some textboxes bound to the...
3
by: sck10 | last post by:
Hello, I am trying to bind an arraylist to a FormView DropDownList control in the PreRender state. The error that I get is the following: Databinding methods such as Eval(), XPath(), and...
2
by: Ned Balzer | last post by:
I'm trying to create a formview bound to a sqldatasource, and use a stored procedure to insert data from the formview into several tables. I have some simplified code below, the real code is much...
4
by: J055 | last post by:
Hi I have 2 update buttons in my FormView ('Apply' and 'OK'). I want both buttons to update the data source but the 'OK' button should redirect afterwards. I can see which button is clicked...
1
by: Brad Baker | last post by:
I have created a usercontrol (ascx file) which contains a formview, inside of the formview I have an EditItemTemplate and an ItemTemplate. Both the EditItemTemplate and ItemTemplate have link...
1
by: SteveT | last post by:
Before I pull out what little hair I have left, I'm swallowing my pride and asking the Oracles of .Net: I'm trying to set a property in a dropdown list control in a FormView, based on a session...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.