468,117 Members | 2,205 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,117 developers. It's quick & easy.

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 4172
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by P. Yanzick | last post: by
1 post views Thread by Brad Baker | last post: by
1 post views Thread by SteveT | last post: by
8 posts views Thread by didacticone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.